feat: add HookConflictError for hook token conflicts#1448
feat: add HookConflictError for hook token conflicts#1448
Conversation
Replace WorkflowRuntimeError with a dedicated HookConflictError class for hook token conflicts. This correctly classifies the error as a USER_ERROR (duplicate token is a user mistake) rather than a RUNTIME_ERROR. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: b4a41cd The changes in this PR will be included in the next version bump. This PR includes changesets to release 20 packages
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 |
🧪 E2E Test Results❌ Some tests failed Summary
❌ Failed Tests▲ Vercel Production (2 failed)nextjs-webpack (1 failed):
sveltekit (1 failed):
🐘 Local Postgres (1 failed)hono-stable (1 failed):
🌍 Community Worlds (55 failed)mongodb (2 failed):
redis (2 failed):
turso (51 failed):
Details by Category❌ ▲ Vercel Production
✅ 💻 Local Development
✅ 📦 Local Production
❌ 🐘 Local Postgres
✅ 🪟 Windows
❌ 🌍 Community Worlds
✅ 📋 Other
❌ Some E2E test jobs failed:
Check the workflow run for details. |
📊 Benchmark Results
workflow with no steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 1 step💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 10 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 25 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) workflow with 50 sequential steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Nitro | Next.js (Turbopack) Promise.all with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.all with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Next.js (Turbopack) | Express Promise.all with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro Promise.race with 10 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.race with 25 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Promise.race with 50 concurrent steps💻 Local Development
▲ Production (Vercel)
🔍 Observability: Nitro | Express | Next.js (Turbopack) Stream Benchmarks (includes TTFB metrics)workflow with stream💻 Local Development
▲ Production (Vercel)
🔍 Observability: Express | Next.js (Turbopack) | Nitro SummaryFastest Framework by WorldWinner determined by most benchmark wins
Fastest World by FrameworkWinner determined by most benchmark wins
Column Definitions
Worlds:
|
There was a problem hiding this comment.
Pull request overview
Adds a dedicated, user-classified error type for hook token conflicts and updates core/tests/docs to use it instead of a generic runtime error.
Changes:
- Introduce
HookConflictErrorin@workflow/errors(extendsWorkflowError) and include the conflictingtoken. - Switch hook conflict handling in core to throw
HookConflictErrorand update related tests/assertions. - Update hook-conflict docs to reference the new error type and add changesets for release.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/errors/src/index.ts | Adds HookConflictError (with token property) and slug for docs linking. |
| packages/core/src/workflow/hook.ts | Throws HookConflictError on hook_conflict events instead of WorkflowRuntimeError. |
| packages/core/src/workflow/hook.test.ts | Updates expectations to assert HookConflictError. |
| packages/core/src/workflow.test.ts | Updates workflow runtime tests to assert HookConflictError on conflicts. |
| packages/core/src/classify-error.test.ts | Adds a regression test ensuring HookConflictError classifies as USER_ERROR. |
| docs/content/docs/errors/hook-conflict.mdx | Updates troubleshooting guidance to reference/catch HookConflictError and show token. |
| .changeset/add-hook-conflict-error.md | Declares patch releases for @workflow/errors and @workflow/core. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| return { success: true, payment }; | ||
| } catch (error) { | ||
| if (error instanceof WorkflowRuntimeError && error.message.includes("hook-conflict")) { // [!code highlight] | ||
| if (error instanceof HookConflictError) { // [!code highlight] |
Summary
HookConflictErrorclass in@workflow/errorsfor hook token conflicts, replacing the genericWorkflowRuntimeErrorHookConflictErrorextendsWorkflowError(notWorkflowRuntimeError), so it correctly classifies asUSER_ERRORrather thanRUNTIME_ERROR— duplicate tokens are a user mistake, not an infrastructure issuetokenproperty so users can programmatically access the conflicting tokenerrors/hook-conflict.mdxto reference the new error typeTest plan
cd packages/core && pnpm test— all 473 tests passpnpm test:docs— all docs typecheck passespnpm build— all 27 packages buildclassify-error.test.tsconfirmsHookConflictErrorclassifies asUSER_ERRORhook.test.tsandworkflow.test.ts🤖 Generated with Claude Code