chore(deps): bump unthrown to 5.0.0-beta.5 - #602
Merged
Conversation
Track the beta.4/beta.5 API changes: match's error handler key renamed
`err` → `errCases`, and the bare error combinators gained the `*Cases` suffix
(`mapErr` → `mapErrCases`, `flatMapErr` → `flatMapErrCases`, `tapErr` →
`tapErrCases`). unthrown@5 now declares `ts-pattern` as a peer dependency, so
`ts-pattern` (^5, catalog 5.9.0) is added to the packages that build against
unthrown (core, worker, examples, tests). Peer range raised to `^5.0.0-beta.5`.
The guide docs still show v4-style `match({ err: (error) => … })` examples and
are left for a separate docs migration pass.
btravers
commented
Jul 27, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the monorepo to unthrown@5.0.0-beta.5 (and @unthrown/vitest@5.0.0-beta.5), migrating call sites and examples to the renamed error-case APIs and ensuring ts-pattern is present where needed to satisfy unthrown’s new peer dependency.
Changes:
- Bumped
unthrown/@unthrown/vitestfrom5.0.0-beta.3→5.0.0-beta.5via the workspace catalog + lockfile refresh. - Migrated worker/client code to
errCasesand*ErrCasescombinator names (mapErrCases,flatMapErrCases,tapErrCases). - Added
ts-patternto the relevant packages (tests/examples and dev deps for build targets) and included a patch changeset for the fixed version group.
Reviewed changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/package.json | Adds ts-pattern so tests satisfy unthrown’s new peer dependency. |
| pnpm-workspace.yaml | Updates catalog pins for unthrown and @unthrown/vitest (and confirms ts-pattern catalog entry). |
| pnpm-lock.yaml | Lockfile update reflecting unthrown@5.0.0-beta.5 and ts-pattern peer resolution. |
| packages/worker/src/worker.ts | Migrates worker error combinators to *ErrCases. |
| packages/worker/src/retry.ts | Migrates retry publish error handling to flatMapErrCases. |
| packages/worker/src/errors.ts | Updates JSDoc example to errCases. |
| packages/worker/package.json | Bumps unthrown peer range and adds ts-pattern to devDependencies. |
| packages/core/src/errors.ts | Updates JSDoc examples to errCases. |
| packages/core/package.json | Bumps unthrown peer range and adds ts-pattern to devDependencies. |
| packages/client/src/interceptors.ts | Updates interceptor JSDoc example to flatMapErrCases. |
| packages/client/src/interceptors.spec.ts | Updates tests to flatMapErrCases. |
| packages/client/src/client.ts | Migrates client error combinators and updates match example to errCases. |
| packages/client/package.json | Bumps unthrown peer range to ^5.0.0-beta.5. |
| examples/basic-order-processing-worker/src/index.ts | Updates example worker creation error handling to tapErrCases. |
| examples/basic-order-processing-worker/package.json | Adds ts-pattern dependency for the example package. |
| examples/basic-order-processing-client/src/index.ts | Updates example client error handling to tapErrCases. |
| examples/basic-order-processing-client/package.json | Adds ts-pattern dependency for the example package. |
| .changeset/bump-unthrown-beta-5.md | Adds a patch changeset documenting the breaking API renames and peer update. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
unthrown@5 declares ts-pattern as its own peer; mirror it here so a consumer of these packages gets the explicit single-copy requirement (and no strict-peer install surprise). The devDependency stays for the local build.
Replace every P._ wildcard with explicit enumeration of the error union
(grouping cases that share a handler), so a new error can't be silently
absorbed. Migrate all docs (guide, README, .agents/rules) off the v4-style
match({ err: (error) => … }) and bare mapErr/flatMapErr/tapErr to the v5
errCases/*Cases matcher API. A retry test that injected an out-of-contract
Error (which only passed because P._ caught anything) now injects the real
in-contract TechnicalError.
btravers
commented
Jul 27, 2026
TechnicalError is a technical/infrastructure failure never branched on for domain logic, so per unthrown Thesis #1 (E = anticipated domain failures) it belongs in the defect channel, not E. RetryableError / NonRetryableError (the domain-meaningful retryable-vs-terminal distinction) stay modeled. It is minted via the injected `defect` at qualify boundaries (AmqpClient ops, (de)compression, schema validation), `throw`→defect inside combinator callbacks, or `fromSafeThrowable` at imperative/early-return sites. Every AmqpClient op and worker/client pipeline drops it from E (→ never); the ~15 lone-TechnicalError enumerations collapse; observers move to tapDefect / tapFailure and swallows to recoverDefect. The class stays exported as the defect's cause. Because a terminal Defect is a value (not a throw), the consume callback now nacks an unhandled terminal defect to DLX — preserving the pre-migration "terminal technical failure → DLQ" behaviour and preventing a stuck/poison-loop message (an already-succeeded handler must not be re-run on redelivery). Tests assert `toBeDefect` with TechnicalError as cause; docs updated. BREAKING: consumers matching TechnicalError move to the defect arm.
validateSchema (worker) and the publish validateMessage (client) called `schema["~standard"].validate(...)` directly, so a Standard Schema validator that throws *synchronously* would escape before fromPromise wrapped it — out of processMessage / out of publish() as a raw throw, contradicting the error model (a thrown/rejected validator is a defect). Guard the call with the same try/catch → technicalDefect(...) pattern already used at the RPC validation sites, so a sync throw surfaces on the defect channel like a rejection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bumps
unthrown(and@unthrown/vitest) from5.0.0-beta.3to5.0.0-beta.5, cutting a new beta of the contract packages.What changed in unthrown between beta.3 and beta.5
match's error handler renamederr→errCases(it takes the exhaustive ts-pattern matcher). Migrated call sites + JSDoc@examples.*Casessuffix —mapErr→mapErrCases,flatMapErr→flatMapErrCases,tapErr→tapErrCases. Migrated across client, worker (retry/worker), and examples.ts-patternis now a peer dependency of unthrown (^5). Addedts-pattern(catalog5.9.0) to every package that builds against unthrown (core, worker, examples, tests); client already had it.strictPeerDependenciesnow resolves.^5.0.0-beta.5.Gate
format --check,lint,typecheck,knip,test,buildall green.New beta
A
patchchangeset is included; the fixed version group bumps all six packages, so the changesets pipeline cuts3.0.0-beta.1on merge.Follow-up (not in this PR)
The
docs/guide/*.mdguides still contain v4-stylematch({ err: (error) => … })plain-callback examples that predate v5's matcher API. They need a dedicated docs migration to theerrCases: (matcher) => matcher.with(P._, …)form — left out here to keep this a focused dependency bump.