Skip to content

Handle unexpected replies and falsy results without crashing - #2

Merged
2rdzy merged 2 commits into
masterfrom
fix/protocol-handling
Oct 6, 2026
Merged

2rdzy merged 2 commits into
masterfrom
fix/protocol-handling

Conversation

@2rdzy

@2rdzy 2rdzy commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Builds on the test harness in #1 (merge that first; until then this PR also shows its commit).

  • 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. They are now reported 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 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.

Tests cover each case. Against the old code the suite hangs (the crash and the lost callbacks).

2rdzy added 2 commits October 5, 2026 22:14
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.
@2rdzy
2rdzy merged commit 27d4e46 into master Oct 6, 2026
4 of 6 checks passed
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