-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
http: revert #14024 writable is never set to false
Setting writable = false in IncomingMessage.end made some errors being swallowed in some very popular OSS libraries that we must support. This commit add some of those use cases to the tests, so we avoid further regressions. We should reevaluate how to set writable = false in IncomingMessage in a way that does not break the ecosystem. See: #14024 Fixes: #15029 PR-URL: #15404 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
- Loading branch information
Showing
4 changed files
with
50 additions
and
8 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { get, createServer } = require('http'); | ||
|
||
// res.writable should not be set to false after it has finished sending | ||
// Ref: https://github.com/nodejs/node/issues/15029 | ||
|
||
let external; | ||
|
||
// Http server | ||
const internal = createServer((req, res) => { | ||
res.writeHead(200); | ||
setImmediate(common.mustCall(() => { | ||
external.abort(); | ||
res.end('Hello World\n'); | ||
})); | ||
}).listen(0); | ||
|
||
// Proxy server | ||
const server = createServer(common.mustCall((req, res) => { | ||
get(`http://127.0.0.1:${internal.address().port}`, common.mustCall((inner) => { | ||
res.on('close', common.mustCall(() => { | ||
assert.strictEqual(res.writable, true); | ||
})); | ||
inner.pipe(res); | ||
})); | ||
})).listen(0, () => { | ||
external = get(`http://127.0.0.1:${server.address().port}`); | ||
external.on('error', common.mustCall((err) => { | ||
server.close(); | ||
internal.close(); | ||
})); | ||
}); |
This file contains 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