Skip to content

Commit 43f663d

Browse files
mattzcareyMatt Carey
andauthored
fix(codemode): extend default dynamic worker timeout (#1806)
Co-authored-by: Matt Carey <matt@cloudflare.com>
1 parent 60e53e0 commit 43f663d

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/codemode": patch
3+
---
4+
5+
Increase the default DynamicWorkerExecutor timeout from 30 seconds to 60 seconds to better support longer-running codemode executions.

docs/codemode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ Executes code in an isolated Cloudflare Worker via `WorkerLoader`.
370370
| Option | Type | Default | Description |
371371
| ---------------- | ----------------- | -------- | ------------------------------------------------------------ |
372372
| `loader` | `WorkerLoader` | required | Worker Loader binding from `env.LOADER` |
373-
| `timeout` | `number` | `30000` | Execution timeout in ms |
373+
| `timeout` | `number` | `60000` | Execution timeout in ms |
374374
| `globalOutbound` | `Fetcher \| null` | `null` | Network access control. `null` = blocked, `Fetcher` = routed |
375375

376376
### `IframeSandboxExecutor`
@@ -413,7 +413,7 @@ sanitizeToolName("delete"); // "delete_"
413413
- Code runs in **isolated Worker sandboxes** — each execution gets its own Worker instance
414414
- External network access (`fetch`, `connect`) is **blocked by default** at the runtime level
415415
- Tool calls are dispatched via Workers RPC, not network requests
416-
- Execution has a configurable **timeout** (default 30 seconds)
416+
- Execution has a configurable **timeout** (default 60 seconds)
417417
- Console output is captured separately and does not leak to the host
418418
- Browser iframe execution runs in a sandboxed iframe with a restrictive CSP by
419419
default. It uses nonce-scoped internal messages, but its timeout cannot preempt

packages/codemode/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ class NodeVMExecutor implements Executor {
533533
| Option | Type | Default | Description |
534534
| ---------------- | ------------------------ | -------- | ------------------------------------------------------------ |
535535
| `loader` | `WorkerLoader` | required | Worker Loader binding from `env.LOADER` |
536-
| `timeout` | `number` | `30000` | Execution timeout in ms |
536+
| `timeout` | `number` | `60000` | Execution timeout in ms |
537537
| `globalOutbound` | `Fetcher \| null` | `null` | Network access control. `null` = blocked, `Fetcher` = routed |
538538
| `modules` | `Record<string, string>` | `{}` | Extra modules importable in the sandbox |
539539

packages/codemode/src/executor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,12 @@ export class ToolDispatcher extends RpcTarget {
159159

160160
// ── DynamicWorkerExecutor ─────────────────────────────────────────────
161161

162+
const DEFAULT_DYNAMIC_WORKER_EXECUTION_TIMEOUT_MS = 60_000;
163+
162164
export interface DynamicWorkerExecutorOptions {
163165
loader: WorkerLoader;
164166
/**
165-
* Timeout in milliseconds for code execution. Defaults to 30000 (30s).
167+
* Timeout in milliseconds for code execution. Defaults to 60000 (60s).
166168
*/
167169
timeout?: number;
168170
/**
@@ -216,7 +218,8 @@ export class DynamicWorkerExecutor implements Executor {
216218

217219
constructor(options: DynamicWorkerExecutorOptions) {
218220
this.#loader = options.loader;
219-
this.#timeout = options.timeout ?? 30000;
221+
this.#timeout =
222+
options.timeout ?? DEFAULT_DYNAMIC_WORKER_EXECUTION_TIMEOUT_MS;
220223
this.#globalOutbound = options.globalOutbound ?? null;
221224
const { "executor.js": _, ...safeModules } = options.modules ?? {};
222225
this.#modules = safeModules;

0 commit comments

Comments
 (0)