mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 22:40:57 +00:00

Invoke callback with ERR_STREAM_ALREADY_FINISHED error if `end()` is called on a finished stream. PR-URL: https://github.com/nodejs/node/pull/28687 Refs: https://github.com/nodejs/node/issues/28667 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
28 lines
651 B
JavaScript
28 lines
651 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const http = require('http');
|
|
|
|
const server = http.createServer(common.mustCall(function(req, res) {
|
|
res.end('testing ended state', common.mustCall());
|
|
res.end(common.mustCall());
|
|
res.on('finish', common.mustCall(() => {
|
|
res.end(common.mustCall((err) => {
|
|
assert.strictEqual(err.code, 'ERR_STREAM_ALREADY_FINISHED');
|
|
server.close();
|
|
}));
|
|
}));
|
|
}));
|
|
|
|
server.listen(0);
|
|
|
|
server.on('listening', common.mustCall(function() {
|
|
http
|
|
.request({
|
|
port: server.address().port,
|
|
method: 'GET',
|
|
path: '/'
|
|
})
|
|
.end();
|
|
}));
|