Skip to content

feat(cli): bulk-cancel runs in a single operation - #3348

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

feat(cli): bulk-cancel runs in a single operation#3348
karthikscale3 merged 2 commits into
mainfrom
bulk-cancel-cli

Conversation

@karthikscale3

@karthikscale3karthikscale3 commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

workflow cancel gains a bulk mode: cancel runs matched by --status (pending or running) or --workflowName in one operation. Adds --limit (1–500), an interactive confirmation prompt (-y/--confirm to skip), a compact outcome summary, and a nonzero exit only when a run genuinely fails.

Why

Operators need to cancel batches of stuck or runaway runs without scripting one CLI call per run.

Docs

This API is v5-only; only v5 docs are updated (configuration/cli-and-web-ui.mdx). No v4 docs are changed.

Stacked on #3347.

🤖 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: 62e1e2b

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

This PR includes changesets to release 16 packages
NameType
@workflow/cliMinor
workflowPatch
@workflow/world-testingPatch
@workflow/corePatch
@workflow/buildersPatch
@workflow/nextPatch
@workflow/nitroPatch
@workflow/vitestPatch
@workflow/web-sharedPatch
@workflow/webPatch
@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

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

ProjectDeploymentActionsUpdated (UTC)
example-nextjs-workflow-turbopackReadyReadyPreviewAug 5, 2026 7:26pm
example-nextjs-workflow-webpackReadyReadyPreviewAug 5, 2026 7:26pm
example-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-astro-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-express-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-fastify-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-hono-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-nestjs-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-nitro-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-nuxt-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-sveltekit-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-tanstack-start-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workbench-vite-workflowReadyReadyPreviewAug 5, 2026 7:26pm
workflow-swc-playgroundReadyReadyPreviewAug 5, 2026 7:26pm
workflow-tarballsReadyReadyPreviewAug 5, 2026 7:26pm
workflow-webReadyReadyPreviewAug 5, 2026 7:26pm
1 Skipped Deployment
ProjectDeploymentActionsUpdated (UTC)
workflow-docsSkippedSkippedAug 5, 2026 7:26pm

@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 Development315304353588
✅ 📦 Local Production329004543744
✅ 🐘 Local Postgres329004543744
✅ 🪟 Windows31200312
✅ 📋 Other206804282496
✅ vercel-multi-region270027
Total150720227117343
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-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

Comment threadpackages/cli/src/lib/bulk-cancel.ts Outdated
@github-actions

github-actionsBot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

📊 Workflow Benchmarks

commit 62e1e2b · Wed, 05 Aug 2026 19:39:36 GMT · run logs

Backend: vercel · app: nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep210 (-85%) 💚1381 🔴 (-4.6%)1422 🔴 (-3.9%)1459 🔴 (-14%)30
TTFSstream241 (-82%) 💚1385 🔴 (-1.7%)1460 🔴 (+2.2%)1481 🔴 (-3.2%)30
TTFShook + stream391 (-71%) 💚1641 🔴 (-5.1%)1738 🔴 (-10%)1767 🔴 (-50%) 💚30
STSO1020 steps (inline)107 (-4.5%)155 (±0%)182 (+6.4%)340 (+20%) 🔻1018
STSO1020 steps (queue-hop)3102 (+3.5%)3102 (+3.5%)3102 (+3.5%)3102 (+3.5%)1
WO1020 steps156922 (-2.8%)156922 (-2.8%)156922 (-2.8%)156922 (-2.8%)1
SLstream latency99 (+2.1%)175 🔴 (+36%) 🔻182 🔴 (+9.6%)228 🔴 (±0%)30
SOstream overhead (text)128 (-3.8%)272 🔴 (+30%) 🔻295 (+30%) 🔻1024 🔴 (+184%) 🔻30
SOstream overhead (structured)131 (+3.1%)426 🔴 (+135%) 🔻825 🔴 (+293%) 🔻1205 🔴 (+341%) 🔻30
📈 STSO distribution vs main (inline / queue-hop histograms)

1020 steps (inline)

Cumulative STSO time: main 157366ms → this run 153282ms (Δ -4084ms, -3%)

 100-150 ms ███████████████████████┃ main 663 this 669 +6
150-200 ms █████████┃██ main 322 this 287 -35
200-250 ms █┃ main 19 this 42 +23
250-300 ms ┃ main 4 this 9 +5
300-350 ms ┃ main 3 this 1 -2
350-400 ms ┃ main 1 this 5 +4
400-450 ms ┃ main 0 this 1 +1
450-500 ms ┃ main 0 this 1 +1
600-650 ms ┃ main 0 this 1 +1
700-750 ms ┃ main 2 this 0 -2
750-800 ms ┃ main 1 this 1 +0
800-850 ms ┃ main 0 this 1 +1
1000-1050 ms ┃ main 1 this 0 -1
1050-1100 ms ┃ main 1 this 0 -1
3900-3950 ms ┃ main 1 this 0 -1

1020 steps (queue-hop)

Cumulative STSO time: main 2996ms → this run 3102ms (Δ +106ms, +4%)

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

eb61361

Wed, 05 Aug 2026 18:09:19 GMT · run logs

vercel / nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep1342 (+204%) 🔻1449 🔴 (+28%) 🔻1473 🔴 (+1.3%)1616 🔴 (+4.5%)30
TTFSstream1301 (+635%) 🔻1391 🔴 (+31%) 🔻1453 🔴 (+37%) 🔻1524 🔴 (+32%) 🔻30
TTFShook + stream1525 (+22%) 🔻1651 🔴 (+20%) 🔻1730 🔴 (+21%) 🔻1874 🔴 (+11%)30
STSO1020 steps (inline)101 (+19%) 🔻162 (+17%) 🔻190 (+16%) 🔻453 (+70%) 🔻1018
STSO1020 steps (queue-hop)2949 (±0%)2949 (±0%)2949 (±0%)2949 (±0%)1
WO1020 steps167748 (+22%) 🔻167748 (+22%) 🔻167748 (+22%) 🔻167748 (+22%) 🔻1
SLstream latency120 (+43%) 🔻183 🔴 (+62%) 🔻229 🔴 (+64%) 🔻419 🔴 (+15%) 🔻30
SOstream overhead (text)128 (+20%) 🔻210 (+29%) 🔻244 (+32%) 🔻500 (+43%) 🔻30
SOstream overhead (structured)134 (+26%) 🔻258 🔴 (+70%) 🔻319 (+89%) 🔻620 (+179%) 🔻30

8c796e5

Wed, 05 Aug 2026 03:38:47 GMT · run logs

vercel / nextjs-turbopack

MetricScenarioBest (ms)P75 (ms)P90 (ms)P99 (ms)Samples
TTFSstep1328 (+50%) 🔻1389 🔴 (+34%) 🔻1457 🔴 (+9.8%)1539 🔴 (+3.8%)30
TTFSstream1332 (+36%) 🔻1398 🔴 (+36%) 🔻1453 🔴 (+39%) 🔻1467 🔴 (+26%) 🔻30
TTFShook + stream1632 (+288%) 🔻1698 🔴 (+31%) 🔻1729 🔴 (+13%)1778 🔴 (+4.0%)30
STSO1020 steps (inline)126 (+48%) 🔻155 (+11%)174 (+4.8%)289 (-33%) 💚1018
STSO1020 steps (queue-hop)3273 (-31%) 💚3273 (-31%) 💚3273 (-31%) 💚3273 (-31%) 💚1
WO1020 steps161627 (+8.1%)161627 (+8.1%)161627 (+8.1%)161627 (+8.1%)1
SLstream latency130 (+59%) 🔻182 🔴 (+69%) 🔻201 🔴 (+70%) 🔻599 🔴 (+254%) 🔻30
SOstream overhead (text)145 (+39%) 🔻213 (+26%) 🔻236 (+32%) 🔻412 (+14%)30
SOstream overhead (structured)145 (+39%) 🔻214 (+22%) 🔻248 (+6.4%)451 (-12%)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.

AI review: blocking issues found

Comment threadpackages/cli/src/lib/bulk-cancel.ts Outdated
for (const run of projected) {
if (!byRunId.has(run.runId)) byRunId.set(run.runId, run);
}
const merged = [...byRunId.values()].sort((a, b) => {

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.

AI Review: Blocking

A pending run has no startedAt, so this sort gives it 0 and orders every pending run behind every running run. slice(0, limit) then drops them: workflow cancel -n <name> --limit 50 against 50+ running runs cancels zero pending runs, even though the fan-out fetched them and the default status set includes pending.

Confirmed with a local test driving performBulkCancel with 5 timestamped running runs plus 3 pending runs at --limit 5: cancelRuns receives only the 5 running IDs.

Reruns do reach the pending runs once the running ones drain, so it self-heals, but a user who asks for both statuses and sees the hasMore guidance has no way to infer that one status is systematically starved. Interleaving the per-status pages round-robin before applying the cap keeps both represented and needs no timestamp that pending runs don't have.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in e2acdb9c6. The per-status pages are now merged round-robin before applying --limit, while preserving backend order within each status and deduping run IDs. Added the regression case with 5 running + 3 pending runs at limit 5; the selected batch now contains both statuses.


// One bulk operation: a single backend request on Vercel, or bounded
// fallback concurrency on local / community worlds.
const result = await cancelRuns(

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.

AI Review: Nit

cancelRuns accepts cancelReason and it is persisted on the run. Stamping something like workflow cancel CLI here would let anyone reading a run afterwards tell an operator bulk cancel apart from an in-workflow one.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Fixed in e2acdb9c6. CLI-triggered cancellation now supplies Cancelled via Workflow CLI as cancelReason for both single-run cancelRun and bulk cancelRuns. Tests cover propagation through the bulk fast path and the local/community fallback event path.

karthikscale3and others added 2 commits August 5, 2026 12:21
Replace the per-run cancel loop in `workflow cancel` with one `cancelRuns`
call, validate `--limit` (1-500), print a compact outcome summary with
per-run lines for surfaced failures, and exit nonzero only when a run fails.
The bulk logic lives in a dependency-injected `performBulkCancel` helper so it
is unit-testable without an oclif harness.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

No backport to stable for 2150798 (AI decision).

This is feature work: it adds a bulk-cancel mode to workflow cancel with new flags (--limit validation, confirmation prompt) and a new performBulkCancel helper, carried by a minor changeset. It also builds on the cancelRuns API and BulkCancelWorkflowRunsResult types that the PR describes as v5-only (main). New capabilities do not belong on a maintenance branch.

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

2150798ca6dda8810607b6fb2d6d3734ed1a1e57

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