Stop response-handler errors from poisoning the nREPL response queue#3896
Merged
Stop response-handler errors from poisoning the nREPL response queue#3896
Conversation
`nrepl-client-filter' decodes a batch of responses from the wire and walks them in a `while' loop, dispatching each in turn. A demoted- errors wrapper guarded the global `nrepl-response-handler-functions' hook but stopped there -- the per-request `nrepl--dispatch-response' call ran unprotected. If that call signaled (because of a buggy callback, or because no handler was registered for the response's id), the loop aborted and any later decoded responses sitting in the queue were dropped. Two changes: - Wrap `nrepl--dispatch-response' in `with-demoted-errors' too. Handler bugs are logged but no longer corrupt the response stream. - Soften `nrepl--dispatch-response''s no-callback case from `error' to `message'. The dispatcher cannot do anything actionable with an unknown id; logging is sufficient. Adds two specs in test/nrepl-client-tests.el covering the soft no-handler path and locking in the dispatcher's "errors propagate unless the filter wraps you" contract.
3190a37 to
3f21e81
Compare
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.
Found during a wider audit of request handling.
nrepl-client-filterdecodes a batch of responses from the wire and walks them in awhileloop, dispatching each in turn. Awith-demoted-errorsguard wrapped the globalnrepl-response-handler-functionshook but stopped there -- the per-requestnrepl--dispatch-responsecall ran unprotected.If that call signaled (because a callback threw, or because no handler was registered for the response's id), the
while (queue-head response-q)loop aborted and any later decoded responses sitting in the queue were dropped on the floor. The next response stream might keep working, but anything already decoded was lost.This PR makes two changes:
nrepl--dispatch-responseinwith-demoted-errorstoo. Handler bugs become log entries, not stream corruption.nrepl--dispatch-response's no-callback case fromerrortomessage. The dispatcher cannot do anything actionable with an unknown id; logging is sufficient and avoids forcing the filter to demote.Two new specs in
test/nrepl-client-tests.elcover the soft no-handler path and lock in the dispatcher's contract (errors propagate unless the filter wraps you).