unthrown icon indicating copy to clipboard operation
unthrown copied to clipboard

unthrown should be a peerDependency of every companion package, not a dependency — two copies diverge in both type and identity

Open btravers opened this issue 3 months ago • 0 comments

Observed live in btravstack/start#99, bumping unthrown 5.5.0 → 5.6.0.

What happened

Every companion package carries unthrown as a regular dependency with a caret range (measured on today's latest of each):

Package dependencies entry
@unthrown/[email protected] unthrown: ^5.1.0
@unthrown/[email protected] unthrown: ^5.4.0
@unthrown/[email protected] unthrown: ^5.5.0
@unthrown/boxed, @unthrown/neverthrow, @unthrown/effect, @unthrown/standard-schema, @unthrown/vitest unthrown: ^5.6.0

(@unthrown/oxlint is fine — it has no runtime need for unthrown.)

Because it is a dependency and not a peer, the package manager is free to give the companion its own copy whenever the app's copy doesn't satisfy the subtree's resolution — an app pinning an exact version, a lockfile that hasn't re-resolved the subtree after a bump, or a minimumReleaseAge window. In btravstack/start the 5.6.0 bump left @unthrown/orpc's subtree on 5.5.0 beside the app's 5.6.0, and pnpm dedupe did not collapse it; only an explicit pnpm update --recursive unthrown did.

Why two copies are broken, not just wasteful

  • Type identity: 5.6.0's NotThenable constraint on map made the two copies' Result/AsyncResult structurally mutually unassignable. The failure surfaces far from the cause, as a wall of AsyncResult$1<…> is not assignable to AsyncResult<…> through then/map/flatMap — in start it broke @btravstack/http's handlers against @unthrown/orpc's ResultHandler, whose .d.ts names the subtree's unthrown.
  • Runtime identity: isResult (and tag-based matching generally) compares across copies — a Result built by the app's copy crossing into a companion holding another copy is exactly the dual-copy hazard the ecosystem's own docs warn about.

Proposed fix

Move unthrown to peerDependencies in all eight companions (kept in devDependencies for the workspace build, the usual protocol), so an application always installs exactly one copy and the resolver errors loudly when the range isn't met instead of silently forking the tree. Semver-wise this is a breaking change for anyone relying on auto-install — worth batching with the next minor/major of each companion.

btravers avatar Aug 24 '26 13:08 btravers