#720·flue

Cloudflare sandbox adapter drops the caller AbortSignal

Author: rikbrownCreated Sep 17, 2026Updated Sep 17, 2026

@flue/runtime 2.0.8, Cloudflare target.

Summary

cfSandboxToSandbox.exec does not forward the caller's AbortSignal to @cloudflare/sandbox. SessionEnv.exec rejects promptly when the signal aborts, as documented in the 2.0.0 changelog, but the command continues to run in the container.

Observed behaviour

When a caller aborts a running command, Flue's exec abort race releases the tool immediately. The underlying command is not cancelled. With a sandbox that permits one command at a time, reads and commands from the next turn wait until the abandoned command ends.

Cause

In packages/runtime/src/cloudflare/cf-sandbox.ts, the adapter passes only cwd, env, and timeout to sandbox.exec:

typescript
const result = await guarded(
  'exec',
  sandbox.exec(command, {
    cwd: execOpts?.cwd,
    env: execOpts?.env,
    timeout: execOpts?.timeoutMs,
  }),
);

@cloudflare/sandbox accepts signal in its exec options, but CloudflareSandboxStub.exec does not declare it and the adapter does not forward it.

Proposed change

diff
 export interface CloudflareSandboxStub {
   exec(command: string, options?: {
     cwd?: string;
     env?: Record<string, string>;
     timeout?: number;
+    signal?: AbortSignal;
   }): Promise<...>;
 }
diff
 sandbox.exec(command, {
   cwd: execOpts?.cwd,
   env: execOpts?.env,
   timeout: execOpts?.timeoutMs,
+  signal: execOpts?.signal,
 })

Impact

An aborted command stops in the container instead of occupying its command slot after the caller has moved on. This lets the next turn use the sandbox without waiting for orphaned work to finish.