Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(provider-core): stop a flooding provider CLI from filling memory #24122

Closedonly21mil(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/24122/headopened View on GitHub

Showing 2 changed files with 77 additions and 3 deletions.

x
0 of 2 viewed, 2 left
52 additions and 0 deletionspackages/provider-core/src/server/snapshotProbe.test.tsModified
View file
@@ -159,3 +159,55 @@
});
});
});
+​
+describe("ProviderCommandOutputLimitError", () => {
+ const collectOversizedOutput = (overflowingStream: "stdout" | "stderr") => {
+ // 9 MiB, one chunk past the 8 MiB cap, from a single shared buffer.
+ const mebibyte = new Uint8Array(1024 * 1024).fill(0x61);
+ const oversized = Stream.fromIterable(Array.from({ length: 9 }, () => mebibyte));
+ const spawner = ChildProcessSpawner.make(() =>
+ Effect.succeed(
+ ChildProcessSpawner.makeHandle({
+ pid: ChildProcessSpawner.ProcessId(1),
+ exitCode: Effect.succeed(ChildProcessSpawner.ExitCode(0)),
+ isRunning: Effect.succeed(false),
+ kill: () => Effect.void,
+ unref: Effect.succeed(Effect.void),
+ stdin: Sink.drain,
+ stdout: overflowingStream === "stdout" ? oversized : Stream.empty,
+ stderr: overflowingStream === "stderr" ? oversized : Stream.empty,
+ all: Stream.empty,
+ getInputFd: () => Sink.drain,
+ getOutputFd: () => Stream.empty,
+ }),
+ ),
+ );
+ return spawnAndCollect(
+ "/usr/local/bin/claude",
+ ChildProcess.make("claude", ["--version"]),