-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
http: emit ERR_STREAM_DESTROYED if the socket is destroyed #29227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,90 @@ | ||||||||||
| 'use strict'; | ||||||||||
|
|
||||||||||
| const common = require('../common'); | ||||||||||
| const { createServer, request } = require('http'); | ||||||||||
|
|
||||||||||
| { | ||||||||||
| const server = createServer((req, res) => { | ||||||||||
| server.close(); | ||||||||||
|
|
||||||||||
| req.socket.destroy(); | ||||||||||
|
|
||||||||||
| res.write('hello', common.expectsError({ | ||||||||||
| code: 'ERR_STREAM_DESTROYED' | ||||||||||
| })); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| server.listen(0, common.mustCall(() => { | ||||||||||
| const req = request({ | ||||||||||
| host: 'localhost', | ||||||||||
| port: server.address().port | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| req.on('response', common.mustNotCall()); | ||||||||||
| req.on('error', common.expectsError({ | ||||||||||
| code: 'ECONNRESET' | ||||||||||
| })); | ||||||||||
|
|
||||||||||
| req.end(); | ||||||||||
| })); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| { | ||||||||||
| const server = createServer((req, res) => { | ||||||||||
| server.close(); | ||||||||||
|
|
||||||||||
| req.socket.destroy(); | ||||||||||
|
|
||||||||||
| const onError = common.expectsError({ | ||||||||||
| code: 'ERR_STREAM_DESTROYED' | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| res.on('error', (err) => onError(err)); | ||||||||||
| res.write('hello'); | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| server.listen(0, common.mustCall(() => { | ||||||||||
| const req = request({ | ||||||||||
| host: 'localhost', | ||||||||||
| port: server.address().port | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| req.on('response', common.mustNotCall()); | ||||||||||
| req.on('error', common.mustCall()); | ||||||||||
|
||||||||||
| req.on('error', common.mustCall()); | |
| req.on('error', common.expectsError({ | |
| code: 'ERR_STREAM_DESTROYED' | |
| })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping @mcollina Does that suggestion above seem good to you? (Seems good to me....)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's going to be 'ECONNRESET' on my machine.
mcollina marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| const { createServer, request } = require('http'); | ||
|
|
||
| { | ||
| const server = createServer((req, res) => { | ||
| server.close(); | ||
|
|
||
| res.end(); | ||
| res.writeContinue(); | ||
|
|
||
| res.on('error', common.expectsError({ | ||
| code: 'ERR_STREAM_WRITE_AFTER_END' | ||
| })); | ||
| }); | ||
|
|
||
| server.listen(0, common.mustCall(() => { | ||
| const req = request({ | ||
| host: 'localhost', | ||
| port: server.address().port | ||
| }); | ||
|
|
||
| req.on('response', common.mustCall((res) => res.resume())); | ||
|
|
||
| req.end(); | ||
| })); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| const { createServer, request } = require('http'); | ||
|
|
||
| { | ||
| const server = createServer((req, res) => { | ||
| server.close(); | ||
|
|
||
| res.end(); | ||
| res.writeProcessing(); | ||
|
|
||
| res.on('error', common.expectsError({ | ||
| code: 'ERR_STREAM_WRITE_AFTER_END' | ||
| })); | ||
| }); | ||
|
|
||
| server.listen(0, common.mustCall(() => { | ||
| const req = request({ | ||
| host: 'localhost', | ||
| port: server.address().port | ||
| }); | ||
|
|
||
| req.on('response', common.mustCall((res) => res.resume())); | ||
|
|
||
| req.end(); | ||
| })); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.