Skip to content

Commit 616c56e

Browse files
committed
fixup: tests + Readable capture
1 parent 1899ada commit 616c56e

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

lib/_stream_readable.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,7 @@ Readable.prototype._destroy = function(err, cb) {
251251
};
252252

253253
Readable.prototype[EE.captureRejectionSymbol] = function(err) {
254-
// TODO(mcollina): remove the destroyed if once errorEmitted lands in
255-
// Readable.
256-
if (!this.destroyed) {
257-
this.destroy(err);
258-
}
254+
this.destroy(err);
259255
};
260256

261257
// Manually shove something into the read() buffer.

test/parallel/test-stream-writable-write-cb-twice.js

+15-12
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ const assert = require('assert');
88
const writable = new Writable({
99
write: common.mustCall((buf, enc, cb) => {
1010
cb();
11-
assert.throws(cb, {
12-
code: 'ERR_MULTIPLE_CALLBACK',
13-
name: 'Error'
14-
});
11+
cb();
1512
})
1613
});
1714
writable.write('hi');
15+
writable.on('error', common.expectsError({
16+
code: 'ERR_MULTIPLE_CALLBACK',
17+
type: Error
18+
}));
1819
}
1920

2021
{
@@ -23,14 +24,15 @@ const assert = require('assert');
2324
write: common.mustCall((buf, enc, cb) => {
2425
cb();
2526
process.nextTick(() => {
26-
assert.throws(cb, {
27-
code: 'ERR_MULTIPLE_CALLBACK',
28-
name: 'Error'
29-
});
27+
cb();
3028
});
3129
})
3230
});
3331
writable.write('hi');
32+
writable.on('error', common.expectsError({
33+
code: 'ERR_MULTIPLE_CALLBACK',
34+
type: Error
35+
}));
3436
}
3537

3638
{
@@ -39,12 +41,13 @@ const assert = require('assert');
3941
write: common.mustCall((buf, enc, cb) => {
4042
process.nextTick(cb);
4143
process.nextTick(() => {
42-
assert.throws(cb, {
43-
code: 'ERR_MULTIPLE_CALLBACK',
44-
name: 'Error'
45-
});
44+
cb();
4645
});
4746
})
4847
});
4948
writable.write('hi');
49+
writable.on('error', common.expectsError({
50+
code: 'ERR_MULTIPLE_CALLBACK',
51+
type: Error
52+
}));
5053
}

0 commit comments

Comments
 (0)