mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
d111d7b91c
Otherwise, this condition would result in an error that just reads `cb is not a function`, and which additionally could have lost stack trace context through a `process.nextTick()` call. PR-URL: https://github.com/nodejs/node/pull/19510 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
50 lines
967 B
JavaScript
50 lines
967 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const { Writable } = require('stream');
|
|
|
|
{
|
|
// Sync + Sync
|
|
const writable = new Writable({
|
|
write: common.mustCall((buf, enc, cb) => {
|
|
cb();
|
|
common.expectsError(cb, {
|
|
code: 'ERR_MULTIPLE_CALLBACK',
|
|
type: Error
|
|
});
|
|
})
|
|
});
|
|
writable.write('hi');
|
|
}
|
|
|
|
{
|
|
// Sync + Async
|
|
const writable = new Writable({
|
|
write: common.mustCall((buf, enc, cb) => {
|
|
cb();
|
|
process.nextTick(() => {
|
|
common.expectsError(cb, {
|
|
code: 'ERR_MULTIPLE_CALLBACK',
|
|
type: Error
|
|
});
|
|
});
|
|
})
|
|
});
|
|
writable.write('hi');
|
|
}
|
|
|
|
{
|
|
// Async + Async
|
|
const writable = new Writable({
|
|
write: common.mustCall((buf, enc, cb) => {
|
|
process.nextTick(cb);
|
|
process.nextTick(() => {
|
|
common.expectsError(cb, {
|
|
code: 'ERR_MULTIPLE_CALLBACK',
|
|
type: Error
|
|
});
|
|
});
|
|
})
|
|
});
|
|
writable.write('hi');
|
|
}
|