Repository navigation
Bound connecting and requests, and clean up on close - #4
Merged
Merged
Conversation
Add node:test tests against a small in-process Electrum server over TCP and TLS (with a committed, test-only certificate), covering requests, errors, concurrency, batches, notifications and close. Run them in CI on Node 18, 20 and 22. Point the repository, bugs and homepage fields at this fork, require Node 18 or later, and publish only index.js and lib.
- Enforce the connect timeout: the socket's 'timeout' event was never handled (and not forwarded by the TLS wrapper), so a stalled connection or TLS handshake hung. Destroy the socket on timeout, fail connect if the socket closes first, and keep the timeout armed until the connection (for TLS, the handshake) is established. Option connectTimeout, default 5000 ms. - Give up if the server accepts the connection but never answers server.version, instead of waiting for ever. - Add an optional requestTimeout (milliseconds, off by default) that fails a request which gets no reply and forgets its callback. - close() now rejects pending requests, cancels the reconnect and keep-alive timers, and stops reconnecting through a flag instead of replacing methods. Timers no longer keep the process alive. - TlsSocketWrapper: write before connect throws a clear error, end and destroy are harmless, removing an unknown listener no longer removes all listeners, and 'timeout' is forwarded.
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.
Builds on the test harness in #1 (merge that first).
timeoutevent was never handled (and the TLS wrapper did not forward it), so a stalled connection or TLS handshake hung. Destroy the socket on timeout, failconnectif the socket closes first, and keep the timeout armed until the connection (for TLS, the handshake) is established. OptionconnectTimeout, default 5000 ms.server.version.requestTimeout(milliseconds, off by default) that fails a request which gets no reply and forgets its callback.close()rejects pending requests (they used to hang for ever), cancels the reconnect and keep-alive timers, and stops reconnecting through a flag instead of replacing methods. Timers no longer keep the process alive: a child process test checks it exits by itself afterclose().TlsSocketWrapper:writebefore connect throws a clear error,end/destroyare harmless, removing an unknown listener no longer removes all listeners, andtimeoutis forwarded.Against the old code the lifecycle tests time out.