Skip to content

Commit 24333fe

Browse files
committed
fix: ensure launched servers in local executor are killed upon timeout
Whenever an eval times out, the abort signal fires but we weren't using it for the serve execution— so it was never properly killed.
1 parent bd7a84a commit 24333fe

File tree

6 files changed

+10
-1
lines changed

6 files changed

+10
-1
lines changed

examples/environments/remote_env/fake-executor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export class FakeRemoteExecutor implements Executor {
6464
appDirectoryPath: string,
6565
rootPromptDef: RootPromptDefinition,
6666
progress: ProgressLogger,
67+
abortSignal: AbortSignal,
6768
logicWhileServing: (serveUrl: string) => Promise<T>,
6869
): Promise<T> {
6970
// Start serving of the app.

runner/orchestration/executors/executor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export const executorSchema = z.object({
6565
z.string().describe('Path to the application directory'),
6666
z.custom<RootPromptDefinition>().describe('Root prompt definition'),
6767
z.custom<ProgressLogger>().describe('Progress logger'),
68+
z
69+
.custom<AbortSignal>()
70+
.describe('Abort Signal to fire when the server should be canceled.'),
6871
z
6972
.function(
7073
z.tuple([z.string().describe('URL of the running server')]),

runner/orchestration/executors/local-executor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ export class LocalExecutor implements Executor {
178178
appDirectoryPath: string,
179179
rootPromptDef: RootPromptDefinition,
180180
progress: ProgressLogger,
181+
abortSignal: AbortSignal,
181182
logicWhileServing: (serveUrl: string) => Promise<ServeTestingResult>,
182183
): Promise<ServeTestingResult | null> {
183184
// Serve testing is explicitly disabled.
@@ -190,6 +191,7 @@ export class LocalExecutor implements Executor {
190191
rootPromptDef,
191192
appDirectoryPath,
192193
progress,
194+
abortSignal,
193195
logicWhileServing,
194196
);
195197
}

runner/orchestration/serve-testing-worker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export async function serveAndTestApp(
3737
appDirectoryPath,
3838
rootPromptDef,
3939
progress,
40+
abortSignal,
4041
async serveUrl => {
4142
progress.log(
4243
rootPromptDef,

runner/run-cli.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ async function runApp(options: Options) {
9696
rootPromptDef,
9797
directory,
9898
new NoopProgressLogger(),
99+
new AbortSignal(),
99100
async url => {
100101
console.log();
101102
console.log(formatTitleCard(`🎉 App is up and running at ${url}`));

runner/workers/serve-testing/serve-app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ export async function serveApp<T>(
99
rootPromptDef: RootPromptDefinition,
1010
appDirectoryPath: string,
1111
progress: ProgressLogger,
12+
abortSignal: AbortSignal,
1213
logicWhileServing: (serveUrl: string) => Promise<T>,
1314
): Promise<T> {
1415
let serveProcess: ChildProcess | null = null;
1516

1617
try {
17-
serveProcess = exec(serveCommand, {cwd: appDirectoryPath});
18+
serveProcess = exec(serveCommand, {cwd: appDirectoryPath, signal: abortSignal});
1819
progress.log(
1920
rootPromptDef,
2021
'eval',

0 commit comments

Comments
 (0)