feat!: adopt unthrown v5 (beta)#337
Merged
Merged
Conversation
Migrate the error combinators (flatMapErr / tapErr) and match's err
handler to unthrown v5's ts-pattern matcher callbacks, and replace the
removed matchTags with result.match({ err: (m) => m.with(tag(...), ...) }).
Also pin the modeled error union on the client's widening Err(...) returns
(Err<E>(...)) to work around a v5-beta covariance regression where a
generic-conditional error union defeats the out-E variance fast path.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates the repo’s fixed version group to unthrown v5.0.0-beta.2, updating code and documentation to the new v5 matcher-callback APIs (ts-pattern-based) and entering Changesets beta pre-mode to publish the next prerelease line.
Changes:
- Bump
unthrownand@unthrown/vitestto5.0.0-beta.2via the workspace catalog (and lockfile regeneration). - Migrate
match/tapErr/flatMapErrusage to v5’s(matcher) => matcher.with(...)callback style across worker/client code, tests, and docs. - Add prerelease configuration (
.changeset/pre.json) and a major changeset for the v5 migration.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pnpm-workspace.yaml | Updates catalog versions for unthrown + @unthrown/vitest to v5 beta.2. |
| pnpm-lock.yaml | Lockfile updates reflecting unthrown v5 beta.2 and new transitive deps (e.g., ts-pattern). |
| packages/worker/src/workflow.ts | Updates TSDoc examples to v5 matcher-callback err handler form. |
| packages/worker/src/worker.ts | Updates createWorkerOrThrow match err branch to v5 matcher callback and imports P. |
| packages/worker/src/errors.ts | Updates documentation prose to refer to result.match/ts-pattern matching instead of removed matchTags. |
| packages/worker/src/cancellation.ts | Updates TSDoc example err handler to v5 matcher callback form. |
| packages/worker/src/activity.ts | Updates middleware example (tapErr) and activity result folding err handling to matcher callback form; imports P. |
| packages/worker/src/activity-contract-errors.spec.ts | Updates tests to v5 tapErr matcher-callback style and imports P. |
| packages/worker/package.json | Bumps unthrown dependency range to ^5.0.0-beta.2. |
| packages/contract/src/errors.ts | Updates docs describing discrimination approach to use result.match(... tag(...)) instead of matchTags. |
| packages/contract/src/errors.spec.ts | Updates test description wording to reflect match/tag-style discrimination. |
| packages/contract/package.json | Bumps unthrown peer dependency range to ^5.0.0-beta.2. |
| packages/client/src/interceptors.ts | Updates interceptor example (flatMapErr) to matcher callback form. |
| packages/client/src/client.ts | Updates TSDoc examples to matcher-callback form; applies explicit Err<...> typing workaround in a few returns. |
| packages/client/src/client.spec.ts | Updates unit tests to matcher-callback err handler form and imports P. |
| packages/client/src/tests/client.spec.ts | Updates integration test match err handler to matcher-callback form and imports P. |
| packages/client/package.json | Bumps unthrown peer dependency range to ^5.0.0-beta.2. |
| examples/order-processing-client/src/client.ts | Migrates from matchTags to result.match({ err: (m) => m.with(tag(...), ...) }). |
| .changeset/pre.json | Enters Changesets prerelease mode with beta tag. |
| .changeset/adopt-unthrown-v5-beta.md | Adds a major changeset describing the breaking migration to unthrown v5 beta. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
…ble line The fresh GHSA-mh99-v99m-4gvg (DoS via unbounded expansion length) reddened the audit gate. Its only patched release is 5.0.8 on the 5.x line — applied via the override (with a temporary minimumReleaseAgeExclude entry; 5.0.8 is younger than the 7-day cutoff, published 2026-07-23). The 2.x line under testcontainers>archiver has NO patched release and a cross-major force is unsafe, so the advisory is ignored via auditConfig.ignoreGhsas with the accepted-risk rationale (expansion input is library-internal glob patterns, never user input) and removal criteria.
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.
Adopts unthrown
5.0.0-beta.3across the fixed version group. On merge this publishes8.0.0-beta.0(major; the two pre-existing patch changesets fold in).Note
Green and ready — no known follow-ups. unthrown
5.0.0-beta.3fixes both v5 inference regressions this branch had hit: the async-flatMapcollapse (fixed in beta.2) and the covariance-widening regression (fixed in beta.3). All 9 explicit-type-arg workarounds inclient.tsare removed; every gate step passes (see below).What changed
changeset pre enter beta(adds.changeset/pre.json).unthrownand@unthrown/vitest4.1.0 → 5.0.0-beta.3; peerunthrown^4.1.0 → ^5.0.0-beta.3inclient/worker/contract. (unthrown+@unthrown/vitestwere already inminimumReleaseAgeExclude, so the strict supply-chain install passed with no change there.)flatMapErr(1: client interceptor retry test) andtapErr(1: activity middleware test) →(matcher) => matcher.with(P._, ...).match'serrhandler (real code) —worker.createWorkerOrThrow,activityfold, plus 2 client specs →(matcher) => matcher.with(P._, ...).matchTags(removed in v5) →result.match({ err: (m) => m.with(tag(...), ...) })in the order-processing-client example (2 folds, 6 tags each, kept exhaustive).@exampleblocks + prose acrossclient.ts/worker(workflow,activity,cancellation,errors) updated to the matcher form.qualify(part C): audited allfromPromisesites — all qualifiers already synchronous, no change. NoasynctapErrbranches. Nounwrap*/orElse/recover/UnwrapErrorusage.Err<Err>(...)/Err<ProxyError>(...)) added on beta.2 are reverted to plainErr(...)— a concreteErrnow widens into the generic error union.Gate status (on
5.0.0-beta.3)pnpm format --checkpnpm lintpnpm typecheckpnpm knippnpm testpnpm buildRegressions hit and resolved upstream
flatMapinference collapse — anAsyncResult-returning callback collapsed the success type tounknown. Fixed in5.0.0-beta.2; thesample-order-processing-clientexample typechecks with no workaround.Err(...)return failed to widen into a generic error union (a generic-conditionalEunion defeated the declaredout Efast path, forcing structural comparison into the invariant ts-patternMatch). Fixed in5.0.0-beta.3; the 9 explicit type args are removed and typecheck stays green.No known follow-ups remain.
Merge
Ready for review. On merge it publishes
8.0.0-beta.0.