Skip to content

Fix agent websocket URL resolution and connection hang - #291

Merged
czerwiukk merged 1 commit into
mainfrom
fix/agent-websocket-url
Jul 22, 2026
Merged

Fix agent websocket URL resolution and connection hang#291
czerwiukk merged 1 commit into
mainfrom
fix/agent-websocket-url

Conversation

@czerwiukk

Copy link
Copy Markdown
Member

What

createAgent could fail to connect on some clusters, and when the agent socket returned a 404 the call hung forever.

  • Use the server-provided websocket URL. POST /room/:id/peer returns peer_websocket_url; when present, the agent now connects using it (swapping the peer socket suffix for the agent one) instead of always deriving /socket/agent/websocket from the Fishjam connect URL. Falls back to the previous derivation when the field is absent, so older deployments keep working.
  • awaitConnected() now rejects on a pre-open socket close (e.g. a 404 during the handshake) instead of hanging indefinitely.

Why separate from the release PR

Split out of the 0.29.0 release PR (#290) so it can be reviewed and merged to main on its own.

Tests

Added tests/agent.test.ts covering URL resolution (suffix swap, protocol normalization, path-prefix preservation, both fallbacks) and connect/resolve/reject behavior. yarn typecheck and the new tests pass.

🤖 Generated with Claude Code

@czerwiukk
czerwiukk requested a review from PiotrWodecki July 22, 2026 11:25
Comment thread packages/js-server-sdk/src/utils.ts Outdated
@czerwiukk
czerwiukk force-pushed the fix/agent-websocket-url branch from 7e280af to 49a9e4a Compare July 22, 2026 13:29
@czerwiukk
czerwiukk requested a review from PiotrWodecki July 22, 2026 13:36
@czerwiukk
czerwiukk merged commit dd4328f into main Jul 22, 2026
2 checks passed
@czerwiukk
czerwiukk deleted the fix/agent-websocket-url branch July 22, 2026 13:58
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