mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
4bec6d13f9
PR-URL: https://github.com/nodejs/node/pull/30623 Refs: https://github.com/nodejs/node/issues/30621 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Rich Trott <rtrott@gmail.com>
53 lines
1003 B
JavaScript
53 lines
1003 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();
|
|
cb();
|
|
})
|
|
});
|
|
writable.write('hi');
|
|
writable.on('error', common.expectsError({
|
|
code: 'ERR_MULTIPLE_CALLBACK',
|
|
name: 'Error'
|
|
}));
|
|
}
|
|
|
|
{
|
|
// Sync + Async
|
|
const writable = new Writable({
|
|
write: common.mustCall((buf, enc, cb) => {
|
|
cb();
|
|
process.nextTick(() => {
|
|
cb();
|
|
});
|
|
})
|
|
});
|
|
writable.write('hi');
|
|
writable.on('error', common.expectsError({
|
|
code: 'ERR_MULTIPLE_CALLBACK',
|
|
name: 'Error'
|
|
}));
|
|
}
|
|
|
|
{
|
|
// Async + Async
|
|
const writable = new Writable({
|
|
write: common.mustCall((buf, enc, cb) => {
|
|
process.nextTick(cb);
|
|
process.nextTick(() => {
|
|
cb();
|
|
});
|
|
})
|
|
});
|
|
writable.write('hi');
|
|
writable.on('error', common.expectsError({
|
|
code: 'ERR_MULTIPLE_CALLBACK',
|
|
name: 'Error'
|
|
}));
|
|
}
|