Skip to content

fix: handle paused parser on socket end (issue #5360)#5389

Merged
mcollina merged 1 commit into
nodejs:mainfrom
mcollina:fix-5360-parser-finish-paused
Jun 8, 2026
Merged

fix: handle paused parser on socket end (issue #5360)#5389
mcollina merged 1 commit into
nodejs:mainfrom
mcollina:fix-5360-parser-finish-paused

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented Jun 8, 2026

Remove assert(!this.paused) from Parser.finish() so that when the HTTP/1
parser is paused under backpressure (body not consumed) and the socket
ends (FIN), the parser can finish gracefully instead of throwing an
uncatchable AssertionError from the socket 'end' handler.

llhttp_finish() already handles paused state by returning ERROR.PAUSED,
which is handled in the existing code path by setting this.paused = true
and returning null.

Fixes #5360

Remove assert(!this.paused) from Parser.finish() so that when the HTTP/1
parser is paused under backpressure (body not consumed) and the socket
ends (FIN), the parser can finish gracefully instead of throwing an
uncatchable AssertionError from the socket 'end' handler.

llhttp_finish() already handles paused state by returning ERROR.PAUSED,
which is handled in the existing code path by setting this.paused = true
and returning null.

Fixes nodejs#5360
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.27%. Comparing base (313f4e0) to head (23d2064).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5389      +/-   ##
==========================================
+ Coverage   93.24%   93.27%   +0.03%     
==========================================
  Files         110      110              
  Lines       36719    36751      +32     
==========================================
+ Hits        34238    34279      +41     
+ Misses       2481     2472       -9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mcollina mcollina merged commit d03fb24 into nodejs:main Jun 8, 2026
38 checks passed
@github-actions github-actions Bot mentioned this pull request Jun 8, 2026
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.

Uncatchable AssertionError: assert(!this.paused) on socket end

3 participants