Skip to content

Commit 5600519

Browse files
committed
test(qa): preserve late Matrix sync failures
1 parent 54fe011 commit 5600519

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

‎extensions/qa-lab/src/live-transports/matrix/substrate/sync.test.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,4 +514,36 @@ describe("matrix sync helpers", () => {
514514
}),
515515
).rejects.toThrow("invalid access token");
516516
});
517+
518+
it("preserves response-body failures raised after its long-poll deadline fires", async () => {
519+
const deadline = new AbortController();
520+
const timeoutSpy = vi.spyOn(AbortSignal, "timeout").mockReturnValue(deadline.signal);
521+
const bodyError = new Error("late Matrix response body failure");
522+
const observer = createMatrixQaRoomObserver({
523+
baseUrl: "http://127.0.0.1:28008/",
524+
fetchImpl: async () =>
525+
new Response(
526+
new ReadableStream({
527+
start(controller) {
528+
deadline.abort();
529+
controller.error(bodyError);
530+
},
531+
}),
532+
),
533+
observedEvents: [],
534+
since: "start-batch",
535+
});
536+
537+
try {
538+
await expect(
539+
observer.waitForOptionalRoomEvent({
540+
predicate: () => false,
541+
roomId: "!room:matrix-qa.test",
542+
timeoutMs: 1_000,
543+
}),
544+
).rejects.toBe(bodyError);
545+
} finally {
546+
timeoutSpy.mockRestore();
547+
}
548+
});
517549
});

‎extensions/qa-lab/src/live-transports/matrix/substrate/sync.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ async function pollMatrixQaRoomObserver(
109109
} catch (error) {
110110
// An empty long-poll is expected at this observer-owned boundary. Other
111111
// request failures stay terminal so auth and protocol defects remain visible.
112-
if (deadlineSignal.aborted) {
112+
if (deadlineSignal.aborted && error === deadlineSignal.reason) {
113113
return;
114114
}
115115
throw error;

0 commit comments

Comments
 (0)