mirror of
https://github.com/nodejs/node.git
synced 2025-05-07 15:35:41 +00:00

A couple of lib/_http_outgoing.js's errors were still in the "old style": `throw new Error(<some message here>)`. This commit migrates those 2 old style errors to the "new style": internal/errors.js's error-system. In the future, changes to these errors' messages won't break semver-major status. With the old style, changes to these errors' messages broke semver-major status. It was inconvenient. Refs: https://github.com/nodejs/node/issues/17709 PR-URL: https://github.com/nodejs/node/pull/17837 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
30 lines
594 B
JavaScript
30 lines
594 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
|
|
// Fix for https://github.com/nodejs/node/issues/14368
|
|
|
|
const server = http.createServer(handle);
|
|
|
|
function handle(req, res) {
|
|
res.on('error', common.mustCall((err) => {
|
|
common.expectsError({
|
|
code: 'ERR_STREAM_WRITE_AFTER_END',
|
|
type: Error
|
|
})(err);
|
|
server.close();
|
|
}));
|
|
|
|
res.write('hello');
|
|
res.end();
|
|
|
|
setImmediate(common.mustCall(() => {
|
|
res.write('world');
|
|
}));
|
|
}
|
|
|
|
server.listen(0, common.mustCall(() => {
|
|
http.get(`http://localhost:${server.address().port}`);
|
|
}));
|