Repository navigation
test(DataHandler): cover deeply nested reply causing decoder stack overflow - #2138
Merged
PavelPashov merged 1 commit intoAug 6, 2026
Merged
Conversation
Contributor
|
@GiHoon1123 thank you for this PR, I'll take a look, however please check #2127 as it might make sense to adapt the change for that PR. |
Contributor
Author
|
Thanks for the pointer! I took a look at #2127 — its Since #2127 is still in progress, this PR still seemed worth having as a fix for the currently released behavior - |
…er stack overflow The RESP3 rewrite (redis#2127) replaced redis-parser with a new Decoder, and as part of that already wraps decoder.write() in try/catch, routing failures through returnFatalError -> recoverFromFatalError the same way other parser-detected fatal errors are handled. The new Decoder still recurses once per level of RESP aggregate nesting with no depth limit (confirmed directly against lib/resp/decoder.ts), so a sufficiently deeply nested reply still throws a RangeError - it's just already caught and routed through the existing recovery path instead of crashing the process. There was no test pinning this down, so this adds one. Fixes redis#2108
GiHoon1123
force-pushed
the
fix-2108-parser-recursion-crash
branch
from
July 28, 2026 05:57
ac38e15 to
831b5d8
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.
Fixes #2108.
redis-parser(and its replacement, the RESP3 Decoder from #2127) recursesonce per level of RESP aggregate nesting with no depth limit, so a
sufficiently deeply nested reply throws a RangeError instead of reporting a
parser error.
#2127 already wraps the decoder call in try/catch and routes failures
through the existing returnFatalError -> recoverFromFatalError path, so
this no longer needs a code change. There was no test pinning that behavior
down for this specific case, so this adds one.
Verified by temporarily removing the try/catch and confirming the new test
fails with the expected RangeError.
Note
Low Risk
The change is narrowly scoped defensive error handling around inbound parsing; the diff here is test-only, with production behavior already aligned to the existing fatal-recovery path.
Overview
This PR’s visible diff adds a regression test in
DataHandlerfor issue #2108: feeding a reply nested ~50,000*1arrays must not throw synchronously and must invokerecoverFromFatalErroronce with aRangeError(“Maximum call stack size exceeded”) and{ offlineQueue: false }.The accompanying fix (described in the PR, not in the snippet above) wraps stream
decoder.writeintry/catchand forwards unexpected errors through the existingreturnFatalError→recoverFromFatalErrorpath so parser stack overflows recover instead of killing the Node process.Reviewed by Cursor Bugbot for commit 831b5d8. Bugbot is set up for automated code reviews on this repo. Configure here.