Skip to content

Live streams on the SDK WebSocket client; streaming on Node.js 18 and 20 - #11

Merged
0xFantomMenace merged 1 commit into
masterfrom
fix/stream-large-messages
Oct 5, 2026
Merged

0xFantomMenace merged 1 commit into
masterfrom
fix/stream-large-messages

Conversation

@0xFantomMenace

Copy link
Copy Markdown
Member

oxa stream opened live subscriptions with the runtime's built-in WebSocket. On Node.js 24.15 that socket closes the connection when a compressed message is larger than about 4 MB once decompressed, so large messages such as the BTC L4 snapshot ended the stream with "websocket error". Node.js 18 and 20 have no built-in WebSocket, so streaming refused to run there.

Live subscriptions now run on the SDK's WebSocket client, which oxa stream replay already uses. In Node.js it connects with the ws package.

  • Output, flags and exit codes are unchanged. NDJSON and pretty lines were compared side by side with the previous build.
  • oxa stream and oxa stream replay now run on Node.js 18 and 20.
  • The SDK channel table, subscribe validation and error codes apply to live streams too.
  • Tests cover a connection with no built-in WebSocket and a live BTC L4 stream on Node.js 24.15.

oxa stream opened its live subscriptions with the runtime's built-in
WebSocket. On Node.js 24.15 that socket closes the connection with code
1006 when a compressed message is larger than about 4 MB once
decompressed. The BTC L4 snapshot is about 9 MB, so
oxa stream subscribe l4_diffs BTC failed there with "websocket error"
and exit code 4, as did any channel with messages that large. Node.js
18 and 20 have no built-in WebSocket, so the stream commands refused to
run on them.

Live subscriptions now run on the SDK's WebSocket client (OxArchiveWs),
which oxa stream replay already uses. In Node.js the SDK connects with
the ws package, with permessage-deflate and with the key and
version=2026-10-01 on the URL, as before. The CLI keeps one WebSocket
implementation, and the SDK's channel table check, subscribe validation
and error codes apply to live streams as well. A ws dependency in the
CLI was the alternative; it would have kept a second implementation of
the same connection next to the one replay uses.

Output, flags and exit codes stay as they were on Node.js 22:
- NDJSON and pretty lines are written by the same handlers. Run side by
  side with the previous build on Node.js 22, the trades, order book,
  L4, Lighter and HIP-3 streams wrote the same lines with the same
  fields.
- Ctrl-C, SIGTERM and --duration-ms exit 0; a server error exits by its
  error_code; a failed connection exits 4.
- The client does not reconnect: a dropped connection ends the command,
  so the output never joins two sessions without a sign of the gap.
- Replies to the client's keep-alive pings are not written, nor are
  messages still in flight after the CLI stops the stream.

Behavior changes:
- oxa stream and oxa stream replay run on Node.js 18 and 20; the
  Node.js 22 check is gone from both.
- A connection error prints "websocket error: WebSocket connection
  error" on every Node.js release. The text after the prefix came from
  the runtime and differed by release (it was empty on Node.js 24.15).
- The dedicated stream verbs need the SDK channel table, as
  oxa stream subscribe and oxa stream replay already did, so on an SDK
  older than 1.12.0 they ask for that release instead of streaming.
  The package already requires ^1.12.0.

Tests drive the SDK client through a stand-in socket and run when the
installed SDK has the channel table; without it they check the SDK
floor message. Two tests connect with no global WebSocket, as on
Node.js 18 and 20. The opt-in live suite streams the BTC L4 snapshot
for ten seconds; it fails with the previous stream code on Node.js
24.15 and passes now. CHANGELOG 1.10.0, the README and the stream help
record the change.
@0xFantomMenace
0xFantomMenace merged commit c2d82c5 into master Oct 5, 2026
2 checks passed
@0xFantomMenace
0xFantomMenace deleted the fix/stream-large-messages branch October 5, 2026 04:14
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.

1 participant