Skip to content

fix: return protocol error for responses routed through the channel - #229

Open
Manuel1234477 wants to merge 1 commit into
bitcoindevkit:masterfrom
Manuel1234477:fix/check-error-on-routed-responses
Open

Manuel1234477 wants to merge 1 commit into
bitcoindevkit:masterfrom
Manuel1234477:fix/check-error-on-routed-responses

Conversation

@Manuel1234477

@Manuel1234477 Manuel1234477 commented Oct 12, 2026 •

Copy link
Copy Markdown

Description

The reader thread only checks for an error field on the response it's waiting for itself. Responses it hands off to other waiting requests go through recv without that check, so call/batch_call end up taking result (which is null) and returning Ok.

Easiest way to hit it is a batch where the server answers out of order and one of the items errors: that item comes back as null instead of Error::Protocol. Same thing can happen with concurrent calls from multiple threads. It also means Client sees a JSON error later on instead of a protocol error, and retries/reconnects when it shouldn't.

Fix is to do the same error check in recv when a response comes in over the channel. Added a test with a mock stream that reproduces it (fails on master).

Related to #95.

Changelog notice

  • Fix error responses being returned as null when routed to another waiting request

@Manuel1234477
Manuel1234477 requested a review from a team as a code owner October 12, 2026 10:07
`_reader_thread` only checks the `error` field on the response the reader
itself is waiting for. Responses it forwards to other waiting requests
were returned by `recv` as-is, so `call`/`batch_call` took `result`
(null) and returned Ok instead of `Error::Protocol`.
@Manuel1234477
Manuel1234477 force-pushed the fix/check-error-on-routed-responses branch from 01a5171 to 6417a0e Compare October 12, 2026 10:07
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