Skip to content

fix(core): reject unsupported Hook retention inside QuickJS - #3332

Draft
NathanColosimo wants to merge 2 commits into
mainfrom
codex/quickjs-hook-capability
Draft

fix(core): reject unsupported Hook retention inside QuickJS#3332
NathanColosimo wants to merge 2 commits into
mainfrom
codex/quickjs-hook-capability

Conversation

@NathanColosimo

@NathanColosimo NathanColosimo commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • install the World's capabilities in the QuickJS guest context, matching the node:vm engine
  • reject unsupported retained Hooks synchronously from createHook()
  • remove the host-side operation scan and duplicated terminal-drain checks

Root cause

The merged QuickJS retention fix validated World support only after the VM returned. That failed loudly for uncaught calls, but it could not match the node engine's synchronous createHook() semantics: workflow code could not catch the error, and unsupported Hooks briefly entered the pending-operation state.

QuickJS now receives the same world.capabilities object that the node engine places on WorkflowOrchestratorContext. The guest checks it before correlation IDs are generated or the Hook is registered.

Follow-up to #3319.

Testing

  • pnpm vitest run src/runtime/quickjs-runtime.test.ts
  • pnpm --filter @workflow/core typecheck
  • pnpm --filter @workflow/core build
  • pnpm --filter @workflow/core test (1,908 passed; 3 expected failures)

@changeset-bot

changeset-bot Bot commented Aug 4, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d7bfda9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 16 packages
Name Type
@workflow/core Patch
@workflow/builders Patch
@workflow/cli Patch
@workflow/next Patch
@workflow/nitro Patch
@workflow/vitest Patch
@workflow/web-shared Patch
@workflow/web Patch
workflow Patch
@workflow/world-testing Patch
@workflow/astro Patch
@workflow/nest Patch
@workflow/rollup Patch
@workflow/sveltekit Patch
@workflow/vite Patch
@workflow/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
example-nextjs-workflow-turbopack Ready Ready Preview Aug 4, 2026 11:10pm
example-nextjs-workflow-webpack Ready Ready Preview Aug 4, 2026 11:10pm
example-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-astro-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-express-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-fastify-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-hono-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-nestjs-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-nitro-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-nuxt-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-sveltekit-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-tanstack-start-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workbench-vite-workflow Ready Ready Preview Aug 4, 2026 11:10pm
workflow-docs Ready Ready Preview, v0 Aug 4, 2026 11:10pm
workflow-swc-playground Ready Ready Preview Aug 4, 2026 11:10pm
workflow-tarballs Ready Ready Preview Aug 4, 2026 11:10pm
workflow-web Ready Ready Preview Aug 4, 2026 11:10pm

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit da86e5b · Tue, 04 Aug 2026 20:55:51 GMT · run logs

Backend: vercel · app: nextjs-turbopack

Metric Scenario Best (ms) P75 (ms) P90 (ms) P99 (ms) Samples
TTFS step 283 (+15%) 1525 🔴 (+33%) 🔻 1555 🔴 (+32%) 🔻 1757 🔴 (+16%) 🔻 30
TTFS stream 189 (-26%) 💚 1412 🔴 (+27%) 🔻 1498 🔴 (+30%) 🔻 1557 🔴 (+33%) 🔻 30
TTFS hook + stream 429 (+9.4%) 1706 🔴 (+37%) 🔻 1781 🔴 (+34%) 🔻 2125 🔴 (+48%) 🔻 30
STSO 1020 steps (inline) 95 (-4.0%) 142 (-9.0%) 168 (-11%) 329 (-13%) 1018
STSO 1020 steps (queue-hop) 3807 (+24%) 🔻 3807 (+24%) 🔻 3807 (+24%) 🔻 3807 (+24%) 🔻 1
WO 1020 steps 145072 (-7.1%) 145072 (-7.1%) 145072 (-7.1%) 145072 (-7.1%) 1
SL stream latency 103 (+12%) 198 🔴 (+42%) 🔻 222 🔴 (+17%) 🔻 501 🔴 (-47%) 💚 30
SO stream overhead (text) 119 (-8.5%) 367 🔴 (-3.9%) 677 🔴 (+39%) 🔻 1242 🔴 (+39%) 🔻 30
SO stream overhead (structured) 115 (-16%) 💚 246 (-11%) 379 (-17%) 💚 703 (-10%) 30
📈 STSO distribution vs main (inline / queue-hop histograms)

1020 steps (inline)

Cumulative STSO time: main 151952ms → this run 139824ms (Δ -12128ms, -8%)

 50-100 ms  ┃                         main   1  this   9    +8
100-150 ms  ████████████████████░░░┃  main 687  this 831  +144
150-200 ms  ███┃███                   main 256  this 135  -121
200-250 ms  ┃                         main  42  this  20   -22
250-300 ms  ┃                         main  14  this   9    -5
300-350 ms  ┃                         main   2  this   7    +5
350-400 ms  ┃                         main   8  this   4    -4
400-450 ms  ┃                         main   3  this   1    -2
450-500 ms  ┃                         main   0  this   1    +1
500-550 ms  ┃                         main   2  this   0    -2
550-600 ms  ┃                         main   1  this   0    -1
650-700 ms  ┃                         main   1  this   0    -1
700-750 ms  ┃                         main   1  this   0    -1
800-850 ms  ┃                         main   0  this   1    +1

1020 steps (queue-hop)

Cumulative STSO time: main 3066ms → this run 3807ms (Δ +741ms, +24%)

3000-3500 ms  ┃███████████████████████  main 1  this 0  -1
3500-4000 ms  ░░░░░░░░░░░░░░░░░░░░░░░┃  main 0  this 1  +1
ℹ️ Metric definitions & methodology

The collapsed STSO distribution section above buckets every step gap of the sequential-steps run (not a sampled window), split by whether the step ending the gap ran inline — in the same warm process as the step before it, so the gap is pure framework overhead — or after a queue-hop — the first step of a fresh process, which pays queue dispatch, client reinit and event-log replay. Bars overlay the two runs: is main, marks where this run lands, bridges the gap when this run has more samples in a bucket.

Best/P75/P90/P99 deltas compare against the most recent benchmark run on main at the time of this run. 🔻 flags a delta worse than +15%, 💚 one better than −15%.

Metrics — TTFS: time to first step body (in-deployment start() → first step body, deployment clocks) · STSO: step-to-step overhead (gap between consecutive step bodies) · WO: workflow overhead (whole-run time outside step bodies, in-deployment anchored) · SL: stream latency (in-deployment write → read propagation, readAt - writtenAt) · SO: stream overhead (end-to-end write+consume time beyond the modelled generation window)

Scenarios — step: one trivial no-op step, no stream; no hooks, so the run stays in turbo mode (in-process fast path) · stream: one streaming step; no hooks, so the run stays in turbo mode (in-process fast path) · hook + stream: registers a hook before one step, which exits turbo mode (dispatch path) · 1020 steps: 1020 trivial sequential steps; STSO is measured between consecutive steps in the given step ranges, and WO is the whole-run overhead outside step bodies · stream latency: parallel reader/writer steps on a dedicated stream; SL is the in-deployment write->read propagation (readAt - writtenAt) · stream overhead (text): writer streams 300 variable-length text token deltas paced at 100/s for 3s (a haiku-size LLM's token throughput) while a parallel reader drains the whole stream; SO is the end-to-end write+consume time beyond the 3s generation window (overhead/backpressure) · stream overhead (structured): same workload as stream overhead (text), but each delta is an AI-SDK-style structured object ({ type: 'text-delta', id, text }) instead of a raw string, so the SO gap vs the text scenario is the added serialization cost

🔴 marks a percentile over its target (within target is left unmarked). Targets (p75/p90/p99, ms) — TTFS 200/300/600 · SL 50/60/125 · SO 250/500/1000

All metrics are measured from deployment-side timestamps only. Runs are triggered by an in-deployment route that stamps the anchor (clientStart) right before start(), so the CI runner’s request and its path through api.vercel.com sit outside every measured window. TTFS = in-deployment start() → first step body (turbo uses the in-process fast path, non-turbo the dispatch path), and includes the VQS dispatch hop plus any /flow cold start. STSO/WO are measured between step bodies on the deployment. SL is measured inside the workflow (parallel reader/writer steps), so it no longer includes the api.vercel.com read path.

Cold starts are kept in the numbers on purpose — they are part of real bursty-workload latency. The workbench deployment cold-starts the /flow invocation for a large fraction of runs, inflating P75+; the Best column shows the fastest (warm-start) sample for comparison.

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

Some tests failed

❌ Failed E2E Tests

💻 Local Development (1 failed)

nextjs-webpack-canary-quickjs (1 failed):

  • sleepWinsRaceWorkflow | wrun_41KZ7855H60GM5ME8GQ1R41JMT

📦 Local Production (1 failed)

sveltekit-stable-node (1 failed):

  • webhookWorkflow | wrun_41KZ782QNN0GTN1HA63Z3V59D2

🐘 Local Postgres (1 failed)

sveltekit-stable-quickjs (1 failed):

  • hookTokenReuseLoopWorkflow - same run recreates a hook with the same token after dispose() | wrun_41KZ78Q2VR0GYJAMZ6Z9SJ10E2

E2E Test Summary

Summary
Passed Failed Skipped Total
✅ ▲ Vercel Production 2932 0 500 3432
❌ 💻 Local Development 3289 1 454 3744
❌ 📦 Local Production 3289 1 454 3744
❌ 🐘 Local Postgres 3289 1 454 3744
✅ 🪟 Windows 312 0 0 312
✅ 📋 Other 2068 0 428 2496
✅ vercel-multi-region 27 0 0 27
Total 15206 3 2290 17499
Details by Category

✅ ▲ Vercel Production

App Passed Failed Skipped
✅ astro-node 127 0 29
✅ astro-quickjs 127 0 29
✅ example-node 127 0 29
✅ example-quickjs 127 0 29
✅ express-node 127 0 29
✅ express-quickjs 127 0 29
✅ fastify-node 127 0 29
✅ fastify-quickjs 127 0 29
✅ hono-node 127 0 29
✅ hono-quickjs 127 0 29
✅ nextjs-turbopack-node 152 0 4
✅ nextjs-turbopack-quickjs 152 0 4
✅ nextjs-webpack-node 152 0 4
✅ nextjs-webpack-quickjs 152 0 4
✅ nitro-node 127 0 29
✅ nitro-quickjs 127 0 29
✅ nuxt-node 127 0 29
✅ nuxt-quickjs 127 0 29
✅ sveltekit-node 146 0 10
✅ sveltekit-quickjs 146 0 10
✅ vite-node 127 0 29
✅ vite-quickjs 127 0 29

❌ 💻 Local Development

App Passed Failed Skipped
✅ astro-stable-node 130 0 26
✅ astro-stable-quickjs 130 0 26
✅ express-stable-node 130 0 26
✅ express-stable-quickjs 130 0 26
✅ fastify-stable-node 130 0 26
✅ fastify-stable-quickjs 130 0 26
✅ hono-stable-node 130 0 26
✅ hono-stable-quickjs 130 0 26
✅ nextjs-turbopack-canary-node 137 0 19
✅ nextjs-turbopack-canary-quickjs 137 0 19
✅ nextjs-turbopack-stable-node 156 0 0
✅ nextjs-turbopack-stable-quickjs 156 0 0
✅ nextjs-webpack-canary-node 137 0 19
❌ nextjs-webpack-canary-quickjs 136 1 19
✅ nextjs-webpack-stable-node 156 0 0
✅ nextjs-webpack-stable-quickjs 156 0 0
✅ nitro-stable-node 130 0 26
✅ nitro-stable-quickjs 130 0 26
✅ nuxt-stable-node 130 0 26
✅ nuxt-stable-quickjs 130 0 26
✅ sveltekit-stable-node 149 0 7
✅ sveltekit-stable-quickjs 149 0 7
✅ vite-stable-node 130 0 26
✅ vite-stable-quickjs 130 0 26

❌ 📦 Local Production

App Passed Failed Skipped
✅ astro-stable-node 130 0 26
✅ astro-stable-quickjs 130 0 26
✅ express-stable-node 130 0 26
✅ express-stable-quickjs 130 0 26
✅ fastify-stable-node 130 0 26
✅ fastify-stable-quickjs 130 0 26
✅ hono-stable-node 130 0 26
✅ hono-stable-quickjs 130 0 26
✅ nextjs-turbopack-canary-node 137 0 19
✅ nextjs-turbopack-canary-quickjs 137 0 19
✅ nextjs-turbopack-stable-node 156 0 0
✅ nextjs-turbopack-stable-quickjs 156 0 0
✅ nextjs-webpack-canary-node 137 0 19
✅ nextjs-webpack-canary-quickjs 137 0 19
✅ nextjs-webpack-stable-node 156 0 0
✅ nextjs-webpack-stable-quickjs 156 0 0
✅ nitro-stable-node 130 0 26
✅ nitro-stable-quickjs 130 0 26
✅ nuxt-stable-node 130 0 26
✅ nuxt-stable-quickjs 130 0 26
❌ sveltekit-stable-node 148 1 7
✅ sveltekit-stable-quickjs 149 0 7
✅ vite-stable-node 130 0 26
✅ vite-stable-quickjs 130 0 26

❌ 🐘 Local Postgres

App Passed Failed Skipped
✅ astro-stable-node 130 0 26
✅ astro-stable-quickjs 130 0 26
✅ express-stable-node 130 0 26
✅ express-stable-quickjs 130 0 26
✅ fastify-stable-node 130 0 26
✅ fastify-stable-quickjs 130 0 26
✅ hono-stable-node 130 0 26
✅ hono-stable-quickjs 130 0 26
✅ nextjs-turbopack-canary-node 137 0 19
✅ nextjs-turbopack-canary-quickjs 137 0 19
✅ nextjs-turbopack-stable-node 156 0 0
✅ nextjs-turbopack-stable-quickjs 156 0 0
✅ nextjs-webpack-canary-node 137 0 19
✅ nextjs-webpack-canary-quickjs 137 0 19
✅ nextjs-webpack-stable-node 156 0 0
✅ nextjs-webpack-stable-quickjs 156 0 0
✅ nitro-stable-node 130 0 26
✅ nitro-stable-quickjs 130 0 26
✅ nuxt-stable-node 130 0 26
✅ nuxt-stable-quickjs 130 0 26
✅ sveltekit-stable-node 149 0 7
❌ sveltekit-stable-quickjs 148 1 7
✅ vite-stable-node 130 0 26
✅ vite-stable-quickjs 130 0 26

✅ 🪟 Windows

App Passed Failed Skipped
✅ nextjs-turbopack-node 156 0 0
✅ nextjs-turbopack-quickjs 156 0 0

✅ 📋 Other

App Passed Failed Skipped
✅ e2e-local-dev-nest-stable-node 130 0 26
✅ e2e-local-dev-nest-stable-quickjs 130 0 26
✅ e2e-local-dev-tanstack-start-node 130 0 26
✅ e2e-local-dev-tanstack-start-quickjs 130 0 26
✅ e2e-local-postgres-nest-stable-node 130 0 26
✅ e2e-local-postgres-nest-stable-quickjs 130 0 26
✅ e2e-local-postgres-tanstack-start-node 130 0 26
✅ e2e-local-postgres-tanstack-start-quickjs 130 0 26
✅ e2e-local-prod-nest-stable-node 130 0 26
✅ e2e-local-prod-nest-stable-quickjs 130 0 26
✅ e2e-local-prod-tanstack-start-node 130 0 26
✅ e2e-local-prod-tanstack-start-quickjs 130 0 26
✅ e2e-vercel-prod-nest-node 127 0 29
✅ e2e-vercel-prod-nest-quickjs 127 0 29
✅ e2e-vercel-prod-tanstack-start-node 127 0 29
✅ e2e-vercel-prod-tanstack-start-quickjs 127 0 29

✅ vercel-multi-region

App Passed Failed Skipped
✅ nextjs-turbopack 27 0 0

📋 View full workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant