Skip to content

Commit 6277cb3

Browse files
committed
fix(matrix): use JSON-specific idle-timeout diagnostic on bounded JSON read
The non-raw JSON read in performMatrixRequest fell back to the bound reader's default media idle-timeout message ('Matrix media download stalled: ...'), which is misleading for a JSON control-plane read. Pass a JSON-specific onIdleTimeout so a stalled JSON stream now rejects with 'Matrix JSON response stalled: no data received for {ms}ms', letting the timeout diagnostic distinguish a stalled JSON read from a stalled raw/media read. Update the regression assertion accordingly.
1 parent 356e819 commit 6277cb3

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

extensions/matrix/src/matrix/sdk/transport.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ describe("performMatrixRequest", () => {
261261
);
262262
});
263263

264-
it("uses the configured idle-timeout error for stalled JSON downloads", async () => {
264+
it("uses the JSON-specific idle-timeout error for stalled JSON downloads", async () => {
265265
vi.useFakeTimers();
266266
try {
267267
const stream = new ReadableStream<Uint8Array>({
@@ -291,7 +291,7 @@ describe("performMatrixRequest", () => {
291291
});
292292

293293
const rejection = expect(requestPromise).rejects.toThrow(
294-
"Matrix media download stalled: no data received for 50ms",
294+
"Matrix JSON response stalled: no data received for 50ms",
295295
);
296296
await vi.advanceTimersByTimeAsync(60);
297297
await rejection;

extensions/matrix/src/matrix/sdk/transport.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ export async function performMatrixRequest(params: {
364364
`Matrix JSON response exceeds configured size limit (${size} bytes > ${maxBytes} bytes)`,
365365
),
366366
chunkTimeoutMs: params.readIdleTimeoutMs,
367+
onIdleTimeout: ({ chunkTimeoutMs }) =>
368+
new Error(`Matrix JSON response stalled: no data received for ${chunkTimeoutMs}ms`),
367369
});
368370
return {
369371
response,

0 commit comments

Comments
 (0)