fix: set deliveryAttempted on filtered NO_REPLY to prevent timer fallback

This commit is contained in:
openperf 2026-03-14 12:44:26 +08:00
parent bfc7f0d468
commit d4d7af3400
2 changed files with 30 additions and 0 deletions

View File

@ -428,6 +428,21 @@ describe("dispatchCronDelivery — double-announce guard", () => {
expect(deliverOutboundPayloads).not.toHaveBeenCalled();
// No delivery was sent, so delivered stays false.
expect(state.delivered).toBe(false);
// deliveryAttempted must be true so the heartbeat timer does not fire
// a fallback enqueueSystemEvent with the NO_REPLY sentinel text.
expect(state.deliveryAttempted).toBe(true);
// Verify timer guard agrees: shouldEnqueueCronMainSummary returns false
expect(
shouldEnqueueCronMainSummary({
summaryText: "NO_REPLY",
deliveryRequested: true,
delivered: state.delivered,
deliveryAttempted: state.deliveryAttempted,
suppressMainSummary: false,
isCronSystemEvent: () => true,
}),
).toBe(false);
});
it("suppresses NO_REPLY payload with surrounding whitespace", async () => {
@ -440,5 +455,17 @@ describe("dispatchCronDelivery — double-announce guard", () => {
expect(deliverOutboundPayloads).not.toHaveBeenCalled();
expect(state.delivered).toBe(false);
expect(state.deliveryAttempted).toBe(true);
expect(
shouldEnqueueCronMainSummary({
summaryText: " NO_REPLY ",
deliveryRequested: true,
delivered: state.delivered,
deliveryAttempted: state.deliveryAttempted,
suppressMainSummary: false,
isCronSystemEvent: () => true,
}),
).toBe(false);
});
});

View File

@ -325,6 +325,9 @@ export async function dispatchCronDelivery(
(p) => !isSilentReplyText(p.text, SILENT_REPLY_TOKEN),
);
if (payloadsForDelivery.length === 0) {
// Mark attempted so the heartbeat timer does not fire a fallback
// enqueueSystemEvent with the NO_REPLY sentinel text.
deliveryAttempted = true;
return null;
}
if (params.isAborted()) {