Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(codex): avoid quadratic app-server input buffering #8605

Mergedjuliusmarmingemerged 2 commits intomain fromrefs/pull/8605/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 133 additions and 8 deletions.

x
0 of 2 viewed, 2 left
108 additions and 0 deletionspackages/effect-codex-app-server/src/protocol.test.tsModified
View file
@@ -290,6 +290,114 @@
}),
​
+ it.effect("routes a large notification fragmented across thousands of input chunks", () =>
+ Effect.gen(function* () {
+ const { stdio, input, output } = yield* makeInMemoryStdio();
+ const notifications: Array<CodexProtocol.CodexAppServerIncomingNotification> = [];
+ const transport = yield* CodexProtocol.makeCodexAppServerPatchedProtocol({
+ stdio,
+ onNotification: (notification) =>
+ Effect.sync(() => {
+ notifications.push(notification);
+ }),
+ });
+ const response = yield* transport.request("thread/read", {}).pipe(Effect.forkScoped);
+ yield* Queue.take(output);
+​
+ const notification = {
+ method: "turn/diff/updated",
+ params: {
+ threadId: "thread-1",
+ turnId: "turn-1",
+ diff: "x".repeat(4 * 1024 * 1024),
+ },
+ };
+ const bytes = encoder.encode(
+ `${encodeUnknownJsonString(notification)}\n${encodeUnknownJsonString({ id: 1, result: { ok: true } })}\n`,
+ );
+ for (let offset = 0; offset < bytes.length; offset += 1024) {