0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-25 08:19:38 +01:00
nodejs/test/sequential/test-http-writable-true-after-close.js
Rich Trott ee90959071
test: fix test-https-writable-true-after-close
test-https-writable-true-after-close fails intermittently when run with
a lot of competing processes. Move it to sequential for stability.

PR-URL: https://github.com/nodejs/node/pull/15705
Fixes: https://github.com/nodejs/node/issues/15700
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
2017-10-01 19:44:48 -03:00

43 lines
1.1 KiB
JavaScript

'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 internal;
let external;
// Proxy server
const server = createServer(common.mustCall((req, res) => {
get(`http://127.0.0.1:${internal.address().port}`, common.mustCall((inner) => {
const listener = common.mustCall(() => {
assert.strictEqual(res.writable, true);
});
// on CentOS 5, 'finish' is emitted
res.on('finish', listener);
// everywhere else, 'close' is emitted
res.on('close', listener);
inner.pipe(res);
}));
})).listen(0, () => {
// Http server
internal = createServer((req, res) => {
res.writeHead(200);
setImmediate(common.mustCall(() => {
external.abort();
res.end('Hello World\n');
}));
}).listen(0, () => {
external = get(`http://127.0.0.1:${server.address().port}`);
external.on('error', common.mustCall((err) => {
server.close();
internal.close();
}));
});
});