Repository navigation
Handle unexpected replies and falsy results without crashing - #2
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.
- A reply that matches no pending request, a line that is not JSON, and an error that cannot be tied to a request used to throw inside the socket's data handler and take the process down. Report them through onError. - Resolve a request with its real result. 'msg.result || msg' returned the whole message for results such as null (server.ping), 0, '' or false. - requestBatch with no parameters now resolves empty at once; it used to register a callback under the previous request's id and overwrite it. - Fix the method name in blockchainBlock_headers (blockchain.block.headeres). - Log the reason when a keep-alive ping fails; it was dropped.
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; until then this PR also shows its commit).
datahandler and take the process down. They are now reported throughonError.msg.result || msgreturned the whole message for results such asnull(server.ping),0,''orfalse.requestBatchwith no parameters resolves empty at once. It used to register a callback under the previous request's id and overwrite it.blockchainBlock_headers(blockchain.block.headeres).Tests cover each case. Against the old code the suite hangs (the crash and the lost callbacks).