Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

test: clean up the reference provider process after integration runs

dee44ea35d28c3f
diff --git a/backend/src/lib/providerLink.realProvider.e2e.test.ts b/backend/src/lib/providerLink.realProvider.e2e.test.ts
index 7b470ec99..2a09aa045 100644
--- a/backend/src/lib/providerLink.realProvider.e2e.test.ts
+++ b/backend/src/lib/providerLink.realProvider.e2e.test.ts
@@ -49,7 +49,8 @@ let baseUrl = ''
*/
async function bootPublishedProvider(): Promise<string> {
return new Promise<string>((ok, reject) => {
- const proc = spawn('npx', ['tsx', 'src/server.ts'], {
+ // Own the server process directly; killing npx leaves its tsx/server children running.
+ const proc = spawn(process.execPath, ['--import', 'tsx', 'src/server.ts'], {
cwd: PROVIDER_DIR,
// A small per-step pause, not zero. A turn that completes inside one tick cannot be cancelled
// mid-flight, and the cancel path is the one thing here that only exists for a RUNNING turn.
@@ -64,6 +65,7 @@ async function bootPublishedProvider(): Promise<string> {
if (match) { clearTimeout(timer); ok(match[0]) }
})
proc.stderr?.on('data', (chunk: Buffer) => { stderr += chunk.toString() })
+ proc.once('error', (error) => { clearTimeout(timer); reject(error) })
proc.on('exit', (code) => { clearTimeout(timer); reject(new Error(`reference-provider exited ${code}: ${stderr.slice(0, 500)}`)) })
})
}
@@ -87,7 +89,15 @@ describeIf('the real chain, against the published reference-provider', () => {
baseUrl = await bootPublishedProvider()
}, 90_000)
- afterAll(() => { child?.kill('SIGKILL') })
+ afterAll(async () => {
+ const proc = child
+ if (!proc || proc.exitCode !== null || proc.signalCode !== null) return
+ await new Promise<void>((done) => {
+ const timer = setTimeout(() => proc.kill('SIGKILL'), 2_000)
+ proc.once('close', () => { clearTimeout(timer); done() })
+ proc.kill('SIGTERM')
+ })
+ })
beforeEach(() => {
published.length = 0