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