fix(outbound): keep channel send durable when transcript mirror fails (#89626)

This commit is contained in:
clawsweeper
2026-06-03 11:41:16 +00:00
parent 76857b8b32
commit dfe0fd7119
2 changed files with 3 additions and 13 deletions
-4
View File
@@ -3074,9 +3074,6 @@ describe("deliverOutboundPayloads", () => {
});
it("does not fail the channel send when the post-delivery transcript mirror throws", async () => {
// Regression for #89626: a transient session-lock failure on the
// best-effort transcript mirror must not invalidate an already-delivered
// channel message, otherwise the caller retries and re-sends duplicates.
const sendMatrix = vi.fn().mockResolvedValue({ messageId: "m1", roomId: "!room:example" });
mocks.appendAssistantMessageToSessionTranscript.mockClear();
mocks.appendAssistantMessageToSessionTranscript.mockRejectedValueOnce(
@@ -3096,7 +3093,6 @@ describe("deliverOutboundPayloads", () => {
},
});
// Channel delivered exactly once; the mirror failure was swallowed.
expect(sendMatrix).toHaveBeenCalledTimes(1);
expect(results).toHaveLength(1);
const warnCall = requireMockCall(logMocks.warn, "warn");
+3 -9
View File
@@ -1967,15 +1967,9 @@ async function deliverOutboundPayloadsCore(
mediaUrls: deliveredMirror.mediaUrls,
});
if (mirrorText) {
// The transcript mirror is best-effort bookkeeping that runs *after* the
// channel payloads were already delivered (guarded by results.length > 0
// above). A failure here — e.g. transient session-lock contention
// ("session file changed while embedded prompt lock was released") — must
// not propagate, or the caller would treat the whole send as failed and
// re-deliver the already-sent message (duplicate announcements). Match the
// cron delivery path (mirrorDirectDeliveryIntoTranscript) and downgrade
// mirror failures to a warning. The append carries an idempotency key, so
// any later reconciliation stays deduplicated.
// Transcript mirroring is best-effort bookkeeping after platform send.
// Keep mirror failures non-fatal so callers do not retry an already-sent
// channel payload and create duplicate delivery.
try {
const { appendAssistantMessageToSessionTranscript } = await loadTranscriptRuntime();
const mirrorResult = await appendAssistantMessageToSessionTranscript({