Skip to content

feat!: adopt unthrown v5 (beta)#337

Merged
btravers merged 5 commits into
mainfrom
chore/unthrown-v5-beta
Jul 26, 2026
Merged

feat!: adopt unthrown v5 (beta)#337
btravers merged 5 commits into
mainfrom
chore/unthrown-v5-beta

Conversation

@btravers

@btravers btravers commented Jul 26, 2026

Copy link
Copy Markdown
Collaborator

Adopts unthrown 5.0.0-beta.3 across the fixed version group. On merge this publishes 8.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.3 fixes both v5 inference regressions this branch had hit: the async-flatMap collapse (fixed in beta.2) and the covariance-widening regression (fixed in beta.3). All 9 explicit-type-arg workarounds in client.ts are removed; every gate step passes (see below).

What changed

  • Beta pre-mode: changeset pre enter beta (adds .changeset/pre.json).
  • Version bump (catalog): unthrown and @unthrown/vitest 4.1.0 → 5.0.0-beta.3; peer unthrown ^4.1.0 → ^5.0.0-beta.3 in client / worker / contract. (unthrown + @unthrown/vitest were already in minimumReleaseAgeExclude, so the strict supply-chain install passed with no change there.)
  • API migration to v5's ts-pattern matcher callbacks:
    • Error combinators — flatMapErr (1: client interceptor retry test) and tapErr (1: activity middleware test) → (matcher) => matcher.with(P._, ...).
    • match's err handler (real code) — worker.createWorkerOrThrow, activity fold, 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).
    • TSDoc @example blocks + prose across client.ts / worker (workflow, activity, cancellation, errors) updated to the matcher form.
  • qualify (part C): audited all fromPromise sites — all qualifiers already synchronous, no change. No async tapErr branches. No unwrap* / orElse / recover / UnwrapError usage.
  • Covariance workarounds removed (beta.3): the 9 explicit-type-arg returns (Err<Err>(...) / Err<ProxyError>(...)) added on beta.2 are reverted to plain Err(...) — a concrete Err now widens into the generic error union.

Gate status (on 5.0.0-beta.3)

step result
pnpm format --check
pnpm lint
pnpm typecheck ✅ (12/12 tasks, no explicit-type-arg workarounds)
pnpm knip
pnpm test ✅ (354 tests across 27 files)
pnpm build ✅ (incl. docs)

Regressions hit and resolved upstream

  • Async flatMap inference collapse — an AsyncResult-returning callback collapsed the success type to unknown. Fixed in 5.0.0-beta.2; the sample-order-processing-client example typechecks with no workaround.
  • Covariance widening — a concrete Err(...) return failed to widen into a generic error union (a generic-conditional E union defeated the declared out E fast path, forcing structural comparison into the invariant ts-pattern Match). Fixed in 5.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.

btravers added 3 commits July 26, 2026 17:40
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.
@btravers
btravers marked this pull request as ready for review July 26, 2026 16:48
Copilot AI review requested due to automatic review settings July 26, 2026 16:48

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 unthrown and @unthrown/vitest to 5.0.0-beta.2 via the workspace catalog (and lockfile regeneration).
  • Migrate match/tapErr/flatMapErr usage 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

Comment thread .changeset/adopt-unthrown-v5-beta.md Outdated
btravers added 2 commits July 26, 2026 23:05
…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.
@btravers
btravers merged commit 9260ae0 into main Jul 26, 2026
11 checks passed
@btravers
btravers deleted the chore/unthrown-v5-beta branch July 26, 2026 21:40
Sign up for free to 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