2019-07-14 22:11:06 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
|
|
|
|
const assert = require('assert');
|
|
|
|
const stream = require('stream');
|
|
|
|
|
|
|
|
const writable = new stream.Writable();
|
|
|
|
writable._write = (chunk, encoding, cb) => {
|
|
|
|
setTimeout(() => cb(), 10);
|
|
|
|
};
|
|
|
|
|
|
|
|
writable.end('testing ended state', common.mustCall());
|
|
|
|
writable.end(common.mustCall());
|
|
|
|
writable.on('finish', common.mustCall(() => {
|
2019-09-28 07:33:47 +02:00
|
|
|
let ticked = false;
|
2019-07-14 22:11:06 +02:00
|
|
|
writable.end(common.mustCall((err) => {
|
2019-09-28 07:33:47 +02:00
|
|
|
assert.strictEqual(ticked, true);
|
2019-07-14 22:11:06 +02:00
|
|
|
assert.strictEqual(err.code, 'ERR_STREAM_ALREADY_FINISHED');
|
|
|
|
}));
|
2019-09-28 07:33:47 +02:00
|
|
|
ticked = true;
|
2019-07-14 22:11:06 +02:00
|
|
|
}));
|