Skip to content

FCE-3580: define tsunami error model - #577

Merged
MiloszFilimowski merged 2 commits into
tsunami-migrationfrom
mfilimowski/FCE-3580
Jul 31, 2026
Merged

FCE-3580: define tsunami error model#577
MiloszFilimowski merged 2 commits into
tsunami-migrationfrom
mfilimowski/FCE-3580

Conversation

@MiloszFilimowski

Copy link
Copy Markdown
Collaborator

Description

Answers the FCE-3580 decision ticket: how errors surface in tsunami's API.

The decision (documented in packages/tsunami/AGENTS.md): both surfaces, one error object — a failing imperative method rejects with a typed FishjamError subclass, and the same object is mirrored into the matching ClientState field; a later success clears it. Applied to the three ticket paths:

Path Contract
Device acquisition Rejects with a DeviceError subclass; same object in cameraError/microphoneError. initializeDevices resolves with a result — degraded init is a supported outcome.
addTrack in a room refusing the track kind Rejects with TrackTypeError — never a synchronous throw (the legacy sync throw becomes a rejection; adapter keeps the pinned keep-local recovery).
connect() Rejects with AuthError/JoinError/SocketError/ConnectionError (never undefined, never hangs) and sets peerStatus: "error" from the same event list.

Code in this PR is deliberately minimal: the FishjamError base (cause + recoverability) with ClientDisposedError refactored onto it under src/errors/, plus a one-word lib bump to es2022 for Error.cause typing. Concrete error classes land with their first consumer (device controller, connect state machine, addTrack migration) per the YAGNI rule in AGENTS.md.

Motivation and Context

The FCE-3030 test review (#543) showed these paths had the weakest coverage because there was nothing stable to assert on: legacy connect() rejects with undefined (the test fake had to reject with a real Error to be testable at all — making the suite stricter than production), device failures surface through four different mechanisms, and TrackTypeError's synchronous throw is specified only by a comment in the fake. Typed errors make every path testable as await expect(op).rejects.toBeInstanceOf(X) plus a state assertion — first-class, not incidental.

Documentation impact

  • Documentation updated (packages/tsunami/AGENTS.md carries the decision)

Types of changes

  • New feature (non-breaking change which adds functionality)

@linear

linear Bot commented Jul 30, 2026

Copy link
Copy Markdown

FCE-3580

@MiloszFilimowski
MiloszFilimowski requested review from Tay0108, Copilot and czerwiukk and removed request for Tay0108 and czerwiukk July 30, 2026 15:08

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@MiloszFilimowski
MiloszFilimowski changed the base branch from main to tsunami-migration July 30, 2026 19:24
Document the error-model decision in packages/tsunami/AGENTS.md: every
failing imperative method rejects with a typed FishjamError subclass and
the same object is mirrored into the matching ClientState field, applied
to device acquisition, addTrack (TrackTypeError becomes a rejection), and
connect() (typed rejections consistent with peerStatus).

Land the base primitive: FishjamError (cause + recoverability) with
ClientDisposedError refactored onto it under src/errors/. Concrete error
classes land with their first consumer in the follow-up tickets.

Bump the base tsconfig lib to es2022 for Error.cause typing (tsunami is
the only package extending it).
@MiloszFilimowski
MiloszFilimowski merged commit 807c846 into tsunami-migration Jul 31, 2026
@MiloszFilimowski
MiloszFilimowski deleted the mfilimowski/FCE-3580 branch July 31, 2026 09:27
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.

3 participants