Skip to content

Commit fbd62a6

Browse files
shivamhwpclaude
andcommitted
test(client): keep one slow-config regression for frame parts
One case in session.test.ts now covers what the shared splitter test and the stalled-transfer case checked: a multi-byte config arriving at 4,000 bytes/s through a UTF-8 round trip reassembles and keeps the session alive. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f9de2a0 commit fbd62a6

3 files changed

Lines changed: 7 additions & 46 deletions

File tree

‎packages/client-runtime/src/rpc/session.test.ts‎

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,8 @@ describe("RpcSessionFactory", () => {
285285
const socket = yield* awaitSocket(sockets);
286286
socket.open();
287287
const request = yield* awaitRequest(socket);
288-
const config = { ...SERVER_CONFIG, cwd: "/" + "x".repeat(320 * 1024) };
288+
// Multi-byte text, so parts must be sized in UTF-8 bytes and never split a surrogate pair.
289+
const config = { ...SERVER_CONFIG, cwd: "/" + "é€😀x".repeat(32 * 1024) };
289290
const frame = encodeJson({
290291
_tag: "Chunk",
291292
requestId: request.id,
@@ -294,36 +295,15 @@ describe("RpcSessionFactory", () => {
294295
const parts = new URL(socket.url).searchParams.has("frameParts")
295296
? splitSocketFrame(frame)
296297
: [frame];
297-
expect(parts.length).toBeGreaterThan(1);
298-
expect(yield* session.inboundFrames).toBe(0);
299298

300-
for (const [index, part] of parts.entries()) {
301-
yield* TestClock.adjust((new TextEncoder().encode(part).length / 4000) * 1000);
302-
socket.serverMessage(part);
303-
expect(yield* session.inboundFrames).toBe(index + 1);
299+
for (const part of parts) {
300+
const bytes = new TextEncoder().encode(part);
301+
yield* TestClock.adjust((bytes.length / 4000) * 1000);
302+
socket.serverMessage(new TextDecoder().decode(bytes));
304303
}
305304
yield* Fiber.join(readyFiber);
306305

307306
expect(yield* session.initialConfig).toEqual(config);
308-
expect(yield* session.inboundFrames).toBe(parts.length);
309-
}),
310-
);
311-
312-
it.effect("times out a config transfer that stops after its first part", () =>
313-
Effect.gen(function* () {
314-
const { factory, sockets } = yield* makeFactory();
315-
const session = yield* factory.connect(PREPARED);
316-
const closed = yield* session.closed.pipe(Effect.flip, Effect.forkChild);
317-
const socket = yield* awaitSocket(sockets);
318-
socket.open();
319-
yield* awaitRequest(socket);
320-
socket.serverMessage('\u001e{"_tag":"Chunk",');
321-
yield* TestClock.adjust("30 seconds");
322-
expect(yield* Fiber.join(closed)).toMatchObject({
323-
reason: "transport",
324-
message: expect.stringContaining("stopped responding for 15s"),
325-
});
326-
expect(socket.readyState).toBe(TestWebSocket.CLOSED);
327307
}),
328308
);
329309

‎packages/shared/src/socketFrameParts.test.ts‎

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎packages/shared/src/socketFrameParts.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const SOCKET_FRAME_PARTS_QUERY_PARAM = "frameParts";
77

88
// WebSocket messages arrive whole. At 4,000 bytes/s each part takes about
99
// 12 seconds, leaving margin before the client's 15-second liveness timeout.
10-
export const SOCKET_FRAME_PART_BYTES = 48 * 1024;
10+
const SOCKET_FRAME_PART_BYTES = 48 * 1024;
1111

1212
// No JSON message starts with a record separator. It marks every part but the last.
1313
const PART_PREFIX = "\u001e";

0 commit comments

Comments
 (0)