') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); feat(world,world-vercel,core): bulk run cancellation primitive by karthikscale3 · Pull Request #3347 · vercel/workflow · GitHub
Skip to content

feat(world,world-vercel,core): bulk run cancellation primitive - #3347

Merged
karthikscale3 merged 2 commits into
mainfrom
bulk-cancel-world-api
Aug 5, 2026
Merged

feat(world,world-vercel,core): bulk run cancellation primitive#3347
karthikscale3 merged 2 commits into
mainfrom
bulk-cancel-world-api

Conversation

@karthikscale3

@karthikscale3karthikscale3 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

Adds a bulk run cancellation primitive across the storage layers:

  • @workflow/worldBulkCancelWorkflowRuns* contract and an optional runs.cancelMany.
  • @workflow/world-vercel — implements cancelMany as a single batched request.
  • @workflow/corecancelRuns helper that uses cancelMany when available and otherwise falls back to bounded-concurrency single-run cancellation.

Why

Cancelling many runs one at a time is slow and noisy. This provides a single primitive that the CLI and dashboard build on top of.

Docs

This API is v5-only; only v5 docs are updated (storage.mdx). No v4 docs are changed.

First of 3 stacked PRs.

🤖 Generated with Claude Code

@karthikscale3
karthikscale3 requested a review from a team as a code ownerAugust 5, 2026 03:10
@changeset-bot

changeset-botBot commented Aug 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 562e739

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

This PR includes changesets to release 20 packages
NameType
@workflow/coreMinor
@workflow/worldMinor
@workflow/world-vercelMinor
@workflow/buildersPatch
@workflow/cliPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/vitestPatch
@workflow/web-sharedPatch
@workflow/webPatch
workflowMinor
@workflow/world-testingPatch
@workflow/world-localPatch
@workflow/world-postgresPatch
@workflow/astroPatch
@workflow/nestPatch
@workflow/rollupPatch
@workflow/sveltekitPatch
@workflow/vitePatch
@workflow/nuxtPatch

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

vercelBot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actionsBot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🧪 E2E Test Results

All tests passed

E2E Test Summary

Summary
PassedFailedSkippedTotal
✅ ▲ Vercel Production293205003432
✅ 💻 Local Development329004543744
✅ 📦 Local Production329004543744
✅ 🐘 Local Postgres329004543744
✅ 🪟 Windows31200312
✅ 📋 Other206804282496
✅ vercel-multi-region270027
Total152090229017499
Details by Category

✅ ▲ Vercel Production

AppPassedFailedSkipped
✅ astro-node127029
✅ astro-quickjs127029
✅ example-node127029
✅ example-quickjs127029
✅ express-node127029
✅ express-quickjs127029
✅ fastify-node127029
✅ fastify-quickjs127029
✅ hono-node127029
✅ hono-quickjs127029
✅ nextjs-turbopack-node15204
✅ nextjs-turbopack-quickjs15204
✅ nextjs-webpack-node15204
✅ nextjs-webpack-quickjs15204
✅ nitro-node127029
✅ nitro-quickjs127029
✅ nuxt-node127029
✅ nuxt-quickjs127029
✅ sveltekit-node146010
✅ sveltekit-quickjs146010
✅ vite-node127029
✅ vite-quickjs127029

✅ 💻 Local Development

AppPassedFailedSkipped
✅ astro-stable-node130026
✅ astro-stable-quickjs130026
✅ express-stable-node130026
✅ express-stable-quickjs130026
✅ fastify-stable-node130026
✅ fastify-stable-quickjs130026
✅ hono-stable-node130026
✅ hono-stable-quickjs130026
✅ nextjs-turbopack-canary-node137019
✅ nextjs-turbopack-canary-quickjs137019
✅ nextjs-turbopack-stable-node15600
✅ nextjs-turbopack-stable-quickjs15600
✅ nextjs-webpack-canary-node137019
✅ nextjs-webpack-canary-quickjs137019
✅ nextjs-webpack-stable-node15600
✅ nextjs-webpack-stable-quickjs15600
✅ nitro-stable-node130026
✅ nitro-stable-quickjs130026
✅ nuxt-stable-node130026
✅ nuxt-stable-quickjs130026
✅ sveltekit-stable-node14907
✅ sveltekit-stable-quickjs14907
✅ vite-stable-node130026
✅ vite-stable-quickjs130026

✅ 📦 Local Production

AppPassedFailedSkipped
✅ astro-stable-node130026
✅ astro-stable-quickjs130026
✅ express-stable-node130026
✅ express-stable-quickjs130026
✅ fastify-stable-node130026
✅ fastify-stable-quickjs130026
✅ hono-stable-node130026
✅ hono-stable-quickjs130026
✅ nextjs-turbopack-canary-node137019
✅ nextjs-turbopack-canary-quickjs137019
✅ nextjs-turbopack-stable-node15600
✅ nextjs-turbopack-stable-quickjs15600
✅ nextjs-webpack-canary-node137019
✅ nextjs-webpack-canary-quickjs137019
✅ nextjs-webpack-stable-node15600
✅ nextjs-webpack-stable-quickjs15600
✅ nitro-stable-node130026
✅ nitro-stable-quickjs130026
✅ nuxt-stable-node130026
✅ nuxt-stable-quickjs130026
✅ sveltekit-stable-node14907
✅ sveltekit-stable-quickjs14907
✅ vite-stable-node130026
✅ vite-stable-quickjs130026

✅ 🐘 Local Postgres

AppPassedFailedSkipped
✅ astro-stable-node130026
✅ astro-stable-quickjs130026
✅ express-stable-node130026
✅ express-stable-quickjs130026
✅ fastify-stable-node130026
✅ fastify-stable-quickjs130026
✅ hono-stable-node130026
✅ hono-stable-quickjs130026
✅ nextjs-turbopack-canary-node137019
✅ nextjs-turbopack-canary-quickjs137019
✅ nextjs-turbopack-stable-node15600
✅ nextjs-turbopack-stable-quickjs15600
✅ nextjs-webpack-canary-node137019
✅ nextjs-webpack-canary-quickjs137019
✅ nextjs-webpack-stable-node15600
✅ nextjs-webpack-stable-quickjs15600
✅ nitro-stable-node130026
✅ nitro-stable-quickjs130026
✅ nuxt-stable-node130026
✅ nuxt-stable-quickjs130026
✅ sveltekit-stable-node14907
✅ sveltekit-stable-quickjs14907
✅ vite-stable-node130026
✅ vite-stable-quickjs130026

✅ 🪟 Windows

AppPassedFailedSkipped
✅ nextjs-turbopack-node15600
✅ nextjs-turbopack-quickjs15600

✅ 📋 Other

AppPassedFailedSkipped
✅ e2e-local-dev-nest-stable-node130026
✅ e2e-local-dev-nest-stable-quickjs130026
✅ e2e-local-dev-tanstack-start-node130026
✅ e2e-local-dev-tanstack-start-quickjs130026
✅ e2e-local-postgres-nest-stable-node130026
✅ e2e-local-postgres-nest-stable-quickjs130026
✅ e2e-local-postgres-tanstack-start-node130026
✅ e2e-local-postgres-tanstack-start-quickjs130026
✅ e2e-local-prod-nest-stable-node130026
✅ e2e-local-prod-nest-stable-quickjs130026
✅ e2e-local-prod-tanstack-start-node130026
✅ e2e-local-prod-tanstack-start-quickjs130026
✅ e2e-vercel-prod-nest-node127029
✅ e2e-vercel-prod-nest-quickjs127029
✅ e2e-vercel-prod-tanstack-start-node127029
✅ e2e-vercel-prod-tanstack-start-quickjs127029

✅ vercel-multi-region

AppPassedFailedSkipped
✅ nextjs-turbopack2700

📋 View full workflow run

@github-actions

github-actionsBot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit 562e739 · Wed, 05 Aug 2026 18:11:44 GMT · run logs

Backend: vercel · app: nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep1308 (+196%) 🔻1671 🔴 (+48%) 🔻1871 🔴 (+29%) 🔻2128 🔴 (+38%) 🔻30
TTFSstream1320 (+646%) 🔻1556 🔴 (+47%) 🔻1622 🔴 (+52%) 🔻1873 🔴 (+62%) 🔻30
TTFShook + stream1617 (+29%) 🔻1888 🔴 (+37%) 🔻2075 🔴 (+45%) 🔻2441 🔴 (+45%) 🔻30
STSO1020 steps (inline)110 (+29%) 🔻164 (+18%) 🔻191 (+16%) 🔻369 (+38%) 🔻1018
STSO1020 steps (queue-hop)3411 (+15%) 🔻3411 (+15%) 🔻3411 (+15%) 🔻3411 (+15%) 🔻1
WO1020 steps173420 (+26%) 🔻173420 (+26%) 🔻173420 (+26%) 🔻173420 (+26%) 🔻1
SLstream latency122 (+45%) 🔻208 🔴 (+84%) 🔻225 🔴 (+61%) 🔻447 🔴 (+23%) 🔻30
SOstream overhead (text)141 (+32%) 🔻260 🔴 (+60%) 🔻299 (+62%) 🔻379 (+8.6%)30
SOstream overhead (structured)133 (+25%) 🔻212 (+39%) 🔻261 (+54%) 🔻647 (+191%) 🔻30
📈 STSO distribution vs main (inline / queue-hop histograms)

1020 steps (inline)

Cumulative STSO time: main 133947ms → this run 168585ms (Δ +34638ms, +26%)

 50-100 ms ┃ main 15 this 0 -15
100-150 ms ████████████████┃███████ main 827 this 569 -258
150-200 ms ████░░░░░░┃ main 137 this 367 +230
200-250 ms ┃ main 23 this 48 +25
250-300 ms ┃ main 10 this 13 +3
300-350 ms ┃ main 3 this 7 +4
350-400 ms ┃ main 2 this 6 +4
400-450 ms ┃ main 0 this 1 +1
450-500 ms ┃ main 0 this 4 +4
500-550 ms ┃ main 1 this 0 -1
550-600 ms ┃ main 0 this 1 +1
4150-4200 ms ┃ main 0 this 1 +1
4800-4850 ms ┃ main 0 this 1 +1

1020 steps (queue-hop)

Cumulative STSO time: main 2956ms → this run 3411ms (Δ +455ms, +15%)

2500-3000 ms ┃███████████████████████ main 1 this 0 -1
3000-3500 ms ░░░░░░░░░░░░░░░░░░░░░░░┃ main 0 this 1 +1
📜 Previous results (2)

e703fbd

Wed, 05 Aug 2026 17:48:25 GMT · run logs

vercel / nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep222 (+9.9%)1376 🔴 (+30%) 🔻1415 🔴 (+26%) 🔻1743 🔴 (+13%)30
TTFSstream210 (-2.8%)1382 🔴 (+30%) 🔻1395 🔴 (+26%) 🔻1463 🔴 (-11%)30
TTFShook + stream458 (+31%) 🔻1611 🔴 (+18%) 🔻1659 🔴 (+17%) 🔻1860 🔴 (+3.9%)30
STSO1020 steps (inline)109 (-0.9%)165 (-3.5%)192 (-4.0%)343 (-2.3%)1018
STSO1020 steps (queue-hop)3934 (+36%) 🔻3934 (+36%) 🔻3934 (+36%) 🔻3934 (+36%) 🔻1
WO1020 steps166328 (-1.8%)166328 (-1.8%)166328 (-1.8%)166328 (-1.8%)1
SLstream latency95 (-2.1%)177 🔴 (-11%)256 🔴 (-1.5%)512 🔴 (-26%) 💚30
SOstream overhead (text)140 (-2.8%)423 🔴 (+74%) 🔻619 🔴 (+99%) 🔻839 (+20%) 🔻30
SOstream overhead (structured)140 (+2.2%)367 🔴 (+44%) 🔻553 🔴 (+37%) 🔻1009 🔴 (+18%) 🔻30

c1c4924

Wed, 05 Aug 2026 03:36:41 GMT · run logs

vercel / nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep1267 (+43%) 🔻1332 🔴 (+29%) 🔻1350 🔴 (+1.7%)1643 🔴 (+11%)30
TTFSstream1243 (+27%) 🔻1293 🔴 (+26%) 🔻1310 🔴 (+26%) 🔻1327 🔴 (+14%)30
TTFShook + stream1481 (+252%) 🔻1600 🔴 (+23%) 🔻1676 🔴 (+9.3%)1805 🔴 (+5.6%)30
STSO1020 steps (inline)58 (-32%) 💚118 (-16%) 💚139 (-16%) 💚214 (-50%) 💚1019
WO1020 steps118705 (-21%) 💚118705 (-21%) 💚118705 (-21%) 💚118705 (-21%) 💚1
SLstream latency93 (+13%)156 🔴 (+44%) 🔻169 🔴 (+43%) 🔻210 🔴 (+24%) 🔻30
SOstream overhead (text)106 (+1.9%)145 (-14%)157 (-12%)200 (-44%) 💚30
SOstream overhead (structured)98 (-5.8%)152 (-14%)179 (-23%) 💚333 (-35%) 💚30
ℹ️ 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.

@VaguelySeriousVaguelySerious left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Human review: just a bit verbose, contract seems fine

'@workflow/world-vercel': minor
---

Add a bulk run cancellation primitive. `@workflow/world` defines the `BulkCancelWorkflowRuns*` contract and an optional `runs.cancelMany`; `@workflow/world-vercel` implements it via a single `POST /v4/runs/cancel`; `@workflow/core` adds a `cancelRuns` helper that uses `cancelMany` when available and falls back to bounded-concurrency single-run cancellation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verbose

Comment threadpackages/world/src/interfaces.ts Outdated
karthikscale3and others added 2 commits August 5, 2026 10:48
Add a bulk cancellation contract to @workflow/world (schemas, types, and an
optional Storage['runs'].cancelMany method), implement it in
@workflow/world-vercel via a single POST /v4/runs/cancel request, and add a
cancelRuns runtime helper to @workflow/core that uses the world fast path
when available and otherwise falls back to bounded-concurrency (max 20)
single-run cancellation.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Peter Wielander <mittgfu@gmail.com>
Signed-off-by: Karthik Kalyan <105607645+karthikscale3@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

No backport to stable for 8d47928 (AI decision).

This commit adds a brand-new bulk run cancellation API surface: a BulkCancelWorkflowRuns* contract and optional runs.cancelMany in @workflow/world, a batched implementation in @workflow/world-vercel, and a new exported cancelRuns helper in @workflow/core. It is purely additive feature work (labeled feat, with minor changesets) and fixes no defect on the maintenance line, so it does not belong on stable.

To override, re-run the Backport to stable workflow manually via workflow_dispatch and paste this commit SHA into the ref input:

8d479283cabd9de84fa2542c4ff16f2697d16399

Sign up for freeto 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.

2 participants

@karthikscale3@VaguelySerious