• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4
5const assert = require('assert');
6const stream = require('stream');
7
8const writable = new stream.Writable();
9writable._write = (chunk, encoding, cb) => {
10  setTimeout(() => cb(), 10);
11};
12
13writable.end('testing ended state', common.mustCall());
14writable.end(common.mustCall());
15writable.on('finish', common.mustCall(() => {
16  let ticked = false;
17  writable.end(common.mustCall((err) => {
18    assert.strictEqual(ticked, true);
19    assert.strictEqual(err.code, 'ERR_STREAM_ALREADY_FINISHED');
20  }));
21  ticked = true;
22}));
23