Repository navigation
Live streams on the SDK WebSocket client; streaming on Node.js 18 and 20 - #11
Merged
Merged
Conversation
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.
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.
oxa streamopened 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 replayalready uses. In Node.js it connects with thewspackage.oxa streamandoxa stream replaynow run on Node.js 18 and 20.