mediator-transport: WS-upgrade diagnostics + inbound resilience (0.4.2) - #2
Merged
Conversation
The connect path collapsed every WebSocket upgrade failure into one opaque "WebSocket failed to open". The browser `error` event is deliberately detail-free; the `close` event that follows carries the `code`/`reason` that says WHY — and the old code discarded it by settling on `error` first. Now settle on `close`, map RFC 6455 codes to causes (1008 → mediator ACL/auth reject, distinct from the target VTA's ACL; 1006 → refused upgrade / TLS / proxy not passing Upgrade), decode the bearer token's `exp` to flag a born-expired/skewed token, attach structured `code`/`reason`/`endpoint` fields, and add a connect timeout so a blackholed upgrade fails fast instead of hanging forever. Adds 4 tests (1008+ACL hint, 1006+proxy, expired bearer, timeout). Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
A single bad inbound message (undecryptable, malformed, unknown sender, or a throw in dispatch) was silently dropped. Add an `onError` hook (default console.warn) and make `_onFrame` fully defensive — decode, unpack, and dispatch each in their own try/catch with a frame fingerprint — so the session logs the bad message and keeps delivering the rest of the queue instead of getting stuck. Bumps to 0.4.2 (with the WS-upgrade diagnostics from the prior commit) and adds a CHANGELOG entry. Signed-off-by: Glenn Gore <glenn.g@affinidi.com>
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.
Summary
Two robustness improvements to
MediatorSession, released as 0.4.2 (additive, within the existing^0.4.1range).1. Actionable diagnostics for failed WebSocket upgrades
A failed upgrade used to collapse into one opaque
WebSocket failed to open. The browsererrorevent is deliberately detail-free, so we now settle on thecloseevent and surface what it carries:Upgradeheader (a CORS-blocked cross-origin upgrade lands here), 1015 → TLS failure.expto flag a born-expired / clock-skewed token.code/reason/endpointfields to the error.connectTimeoutMs(default 15s) so a silently-dropped upgrade fails fast instead of hanging.2. Per-frame inbound resilience
A single bad inbound message (undecryptable, malformed, unknown sender, or a throw in dispatch) was silently dropped. Now:
onErrorhook (defaultconsole.warn);_onFrameis fully defensive (decode / unpack / dispatch each in their own try/catch with a short frame fingerprint).Tests
🤖 Generated with Claude Code