Skip to content

Commit c4cf97c

Browse files
committed
test(daemon-client): assert the bytes a request at the limit delivers
The boundary test checked only that a connection opened. The server now counts the bytes it reads: a request exactly at the limit delivers the whole JSON and its newline, and a request one byte over delivers nothing and reports daemonRequestSent false. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016qAu53rMak1bXMuR5U2gF4
1 parent ef05d73 commit c4cf97c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

‎packages/daemon-client/src/__tests__/daemon-client-transport.test.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -507,10 +507,13 @@ test.for([
507507
'a socket request $overBy bytes over the limit, without its newline, is sent: $sent',
508508
async ({ overBy, sent }, t) => {
509509
if (await skipWhenLoopbackUnavailable(t)) return;
510-
let connections = 0;
510+
let receivedBytes = 0;
511+
// The server reads the whole request line, then drops the connection without answering.
511512
const server = net.createServer((socket) => {
512-
connections += 1;
513-
socket.destroy();
513+
socket.on('data', (chunk: Buffer) => {
514+
receivedBytes += chunk.length;
515+
if (chunk.includes(0x0a)) socket.destroy();
516+
});
514517
});
515518
const port = await listenOnLoopback(server);
516519
const request = (flow: string) => ({
@@ -536,7 +539,9 @@ test.for([
536539
);
537540
assert.ok(outcome instanceof AppError);
538541
assert.equal(outcome.details?.reason === 'daemon_request_too_large', !sent);
539-
assert.equal(connections, sent ? 1 : 0);
542+
if (!sent) assert.equal(outcome.details?.daemonRequestSent, false);
543+
// The whole request and its framing newline reached the daemon, or nothing did.
544+
assert.equal(receivedBytes, sent ? DAEMON_REQUEST_MAX_BYTES + 1 : 0);
540545
} finally {
541546
await closeLoopbackServer(server);
542547
}

0 commit comments

Comments
 (0)