Skip to content

Commit f150b9d

Browse files
only21milcestercianclaude
committed
test(codex): check the length counter resets per message and earlier lines still run
Co-authored-by: Cestercian <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 15cbcfb commit f150b9d

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

‎packages/effect-codex-app-server/src/protocol.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,35 @@ it.layer(NodeServices.layer)("effect-codex-app-server protocol", (it) => {
414414
}),
415415
);
416416

417+
it.effect(
418+
"counts each incoming message from zero and handles earlier lines before rejecting",
419+
() =>
420+
Effect.gen(function* () {
421+
const { stdio, input } = yield* makeInMemoryStdio();
422+
const notifications: Array<CodexProtocol.CodexAppServerIncomingNotification> = [];
423+
const termination = yield* Deferred.make<CodexError.CodexAppServerError>();
424+
yield* CodexProtocol.makeCodexAppServerPatchedProtocol({
425+
stdio,
426+
maxIncomingMessageLength: 16,
427+
onNotification: (notification) =>
428+
Effect.sync(() => {
429+
notifications.push(notification);
430+
}),
431+
onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
432+
});
433+
434+
yield* Queue.offer(input, encoder.encode('{"method":"x/a"}\n{"meth'));
435+
yield* Queue.offer(input, encoder.encode('od":"x/c"}\n{"method":"x/b","p":1}\n'));
436+
yield* Queue.end(input);
437+
438+
assert.instanceOf(
439+
yield* Deferred.await(termination),
440+
CodexError.CodexAppServerTransportError,
441+
);
442+
assert.deepEqual(notifications, [{ method: "x/a" }, { method: "x/c" }]);
443+
}),
444+
);
445+
417446
it.effect("reports a malformed fragmented final line before input stream termination", () =>
418447
Effect.gen(function* () {
419448
const { stdio, input, output } = yield* makeInMemoryStdio();

0 commit comments

Comments
 (0)