• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const http = require('http');
5
6// Fix for https://github.com/nodejs/node/issues/14368
7
8const server = http.createServer(handle);
9
10function handle(req, res) {
11  res.on('error', common.mustCall((err) => {
12    common.expectsError({
13      code: 'ERR_STREAM_WRITE_AFTER_END',
14      name: 'Error'
15    })(err);
16    server.close();
17  }));
18
19  res.write('hello');
20  res.end();
21
22  setImmediate(common.mustCall(() => {
23    res.write('world');
24  }));
25}
26
27server.listen(0, common.mustCall(() => {
28  http.get(`http://localhost:${server.address().port}`);
29}));
30