• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const { Writable } = require('stream');
4
5{
6  // Sync + Sync
7  const writable = new Writable({
8    write: common.mustCall((buf, enc, cb) => {
9      cb();
10      cb();
11    })
12  });
13  writable.write('hi');
14  writable.on('error', common.expectsError({
15    code: 'ERR_MULTIPLE_CALLBACK',
16    name: 'Error'
17  }));
18}
19
20{
21  // Sync + Async
22  const writable = new Writable({
23    write: common.mustCall((buf, enc, cb) => {
24      cb();
25      process.nextTick(() => {
26        cb();
27      });
28    })
29  });
30  writable.write('hi');
31  writable.on('error', common.expectsError({
32    code: 'ERR_MULTIPLE_CALLBACK',
33    name: 'Error'
34  }));
35}
36
37{
38  // Async + Async
39  const writable = new Writable({
40    write: common.mustCall((buf, enc, cb) => {
41      process.nextTick(cb);
42      process.nextTick(() => {
43        cb();
44      });
45    })
46  });
47  writable.write('hi');
48  writable.on('error', common.expectsError({
49    code: 'ERR_MULTIPLE_CALLBACK',
50    name: 'Error'
51  }));
52}
53