mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 02:52:29 +00:00

When a transform stream's callback is called more than once, an error is emitted with a somewhat confusing message. This commit hopes to improve the quality of the error message. Fixes: https://github.com/nodejs/node/issues/12513 PR-URL: https://github.com/nodejs/node/pull/12520 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
15 lines
385 B
JavaScript
15 lines
385 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Transform } = require('stream');
|
|
const stream = new Transform({
|
|
transform(chunk, enc, cb) { cb(); cb(); }
|
|
});
|
|
|
|
stream.on('error', common.mustCall((err) => {
|
|
assert.strictEqual(err.toString(),
|
|
'Error: write callback called multiple times');
|
|
}));
|
|
|
|
stream.write('foo');
|