Skip to content

fix(runtime): de-flake 250ms sandbox hook-timeout tests; honor runner timeout defaults in body-runner#3264

Merged
baozhoutao merged 1 commit into
mainfrom
claude/focused-haslett-273e6d
Jul 19, 2026
Merged

fix(runtime): de-flake 250ms sandbox hook-timeout tests; honor runner timeout defaults in body-runner#3264
baozhoutao merged 1 commit into
mainfrom
claude/focused-haslett-273e6d

Conversation

@baozhoutao

Copy link
Copy Markdown
Contributor

Problem

CI's Test Core intermittently fails on QuickJS sandbox timeout tests — same area, different files, never reproducible locally:

Root cause: every sandbox invocation compiles a fresh WASM module (newAsyncContext()), and a nested hook compiles another one inside the parent hook's 250ms budget. On a loaded CI runner that fixed cost alone can blow the budget — but the failing tests are about nested-write correctness, not about the budget.

Also investigated hook-wrappers.ts runWithTimeout: not a budget source here — it only applies when hook metadata declares timeout, which these tests don't. No change needed there.

Changes

  • body-runner.ts — stop hardcoding the ?? 250 / ?? 5000 fallbacks as an explicit opts.timeoutMs. When neither the body nor the action declares a timeout, leave it unset so QuickJSScriptRunner's constructor defaults (hookTimeoutMs / actionTimeoutMs, same 250/5000 values) apply. Default behavior is unchanged; the previously dead constructor option now works.
  • quickjs-runner.test.ts — the shared runner gets hookTimeoutMs: 10_000 (those tests exercise sandbox behaviour, not the stock budget). The timeout-resolution suite ([P0] Hook sandbox crashes on nested cross-object writes — forces denormalized workarounds across templates #1867) uses a dedicated stock-default runner, and asserts the effective budget via the error message (timeout of 250ms / timeout of 50ms) instead of a wall-clock bound — fully de-timed.
  • nested-write.integration.test.ts / nested-write-real-sqlite.integration.test.ts — construct the runner with hookTimeoutMs: 10_000; their subject is the hook → sandbox → nested-write path.

No changeset: pure bug fix / test de-flake, no functional change to defaults.

Verification

  • packages/runtime sandbox suite (5 files, 50 tests): green across 3 consecutive runs.
  • Full packages/runtime suite: identical pass/fail set before vs. after the change (the 10 local failures are pre-existing worktree environment issues — unbuilt @objectstack/metadata-core, sandboxed network — present at baseline).

🤖 Generated with Claude Code

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 19, 2026 8:17am

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/runtime.

16 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:

  • content/docs/api/index.mdx (via @objectstack/runtime)
  • content/docs/api/wire-format.mdx (via @objectstack/runtime)
  • content/docs/automation/hook-bodies.mdx (via @objectstack/runtime)
  • content/docs/concepts/north-star.mdx (via packages/runtime)
  • content/docs/data-modeling/drivers.mdx (via @objectstack/runtime)
  • content/docs/deployment/index.mdx (via @objectstack/runtime)
  • content/docs/deployment/production-readiness.mdx (via @objectstack/runtime)
  • content/docs/deployment/single-project-mode.mdx (via @objectstack/runtime)
  • content/docs/deployment/vercel.mdx (via @objectstack/runtime)
  • content/docs/getting-started/your-first-project.mdx (via @objectstack/runtime)
  • content/docs/permissions/authentication.mdx (via @objectstack/runtime)
  • content/docs/plugins/packages.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/http-protocol.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/index.mdx (via @objectstack/runtime)
  • content/docs/protocol/kernel/lifecycle.mdx (via @objectstack/runtime)
  • content/docs/releases/implementation-status.mdx (via @objectstack/runtime)

Advisory only. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs origin/main → pass the list as args.docs.

@baozhoutao
baozhoutao merged commit 9498eb4 into main Jul 19, 2026
16 checks passed
@baozhoutao
baozhoutao deleted the claude/focused-haslett-273e6d branch July 19, 2026 08:25
… timeout defaults in body-runner

CI's Test Core intermittently failed sandbox tests with 'hook ... exceeded
timeout of 250ms' (nested-write.integration.test.ts 'rollup_parent_total' on
PR #3263 twice; quickjs-runner.test.ts 'lvl4' on main runs 29678362032 /
29677462748). Root cause: every sandbox invocation compiles a fresh WASM
module (newAsyncContext), and a nested hook compiles another one inside the
parent hook's budget — on a loaded CI runner that fixed cost alone can blow
the 250ms default, while the tests in question are about nested-write
correctness, not the budget.

- body-runner: stop hardcoding the 250ms/5000ms fallbacks as an explicit
  opts.timeoutMs — when neither body nor action declares a timeout, leave it
  unset so QuickJSScriptRunner's constructor defaults (hookTimeoutMs /
  actionTimeoutMs, same 250/5000 values) apply. Default behavior is
  unchanged; the previously dead constructor option now works.
- quickjs-runner.test.ts: shared runner gets hookTimeoutMs 10s (behavioral
  tests); the timeout-resolution suite uses a dedicated stock-default runner
  and asserts the effective budget via the error message ('timeout of
  250ms'/'50ms') instead of a wall-clock bound.
- both nested-write integration tests: construct the runner with
  hookTimeoutMs 10s — their subject is the hook → sandbox → nested-write
  path, not the default budget.

hook-wrappers.ts runWithTimeout was investigated and is not a budget source
here: it only applies when hook metadata declares 'timeout', which these
tests do not.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant