Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 756ac65

Browse filesBrowse files
committed
http: fix crash for sync write errors during header parsing
Fix a crash that occurs when `parser.finish()` is called during `parser.execute()`. In this particular case, this happened because a 100 continue response is a place in which `.end()` can be called which can in turn lead to a write error, which is emitted synchronously, thus inside the outer `parser.execute()` call. Resolve that by delaying the `parser.finish()` call until after the `parser.execute()` call is done. This only affects v12.x, because on later versions, errors are not emitted synchronously. PR-URL: #34251 Fixes: #15102 Fixes: #34016 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 65b7bf4 commit 756ac65
Copy full SHA for 756ac65

File tree

Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-2
lines changed
Open diff view settings
Collapse file

‎lib/_http_client.js‎

Copy file name to clipboardExpand all lines: lib/_http_client.js
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,12 @@ function socketErrorListener(err) {
431431

432432
const parser = socket.parser;
433433
if (parser) {
434-
parser.finish();
435-
freeParser(parser, req, socket);
434+
// Use process.nextTick() on v12.x since 'error' events might be
435+
// emitted synchronously from e.g. a failed write() call on the socket.
436+
process.nextTick(() => {
437+
parser.finish();
438+
freeParser(parser, req, socket);
439+
});
436440
}
437441

438442
// Ensure that no further data will come out of the socket

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.