Skip to content

Commit

Permalink
stream: unify writableErrored and readableErrored
Browse files Browse the repository at this point in the history
Both of these should always refer to the same error, hence
there is no reason to separate them.

PR-URL: #40799
Refs: #40696
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
ronag committed Nov 18, 2021
1 parent 2b0087f commit 340b770
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ added:
Number of times [`writable.uncork()`][stream-uncork] needs to be
called in order to fully uncork the stream.

##### `writable.writableErrored`
##### `writable.errored`

<!-- YAML
added:
Expand Down Expand Up @@ -1389,7 +1389,7 @@ added: v12.9.0

Becomes `true` when [`'end'`][] event is emitted.

##### `readable.readableErrored`
##### `readable.errored`

<!-- YAML
added:
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ ObjectDefineProperties(Readable.prototype, {
}
},

readableErrored: {
errored: {
enumerable: false,
get() {
return this._readableState ? this._readableState.errored : null;
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ ObjectDefineProperties(Writable.prototype, {
}
},

writableErrored: {
errored: {
enumerable: false,
get() {
return this._writableState ? this._writableState.errored : null;
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-stream-finished.js
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
const w = new Writable();
const _err = new Error();
w.destroy(_err);
assert.strictEqual(w.writableErrored, _err);
assert.strictEqual(w.errored, _err);
finished(w, common.mustCall((err) => {
assert.strictEqual(_err, err);
assert.strictEqual(w.closed, true);
Expand All @@ -625,7 +625,7 @@ testClosed((opts) => new Writable({ write() {}, ...opts }));
{
const w = new Writable();
w.destroy();
assert.strictEqual(w.writableErrored, null);
assert.strictEqual(w.errored, null);
finished(w, common.mustCall((err) => {
assert.strictEqual(w.closed, true);
assert.strictEqual(err.code, 'ERR_STREAM_PREMATURE_CLOSE');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-stream-readable-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const assert = require('assert');
read.on('close', common.mustCall());

read.destroy();
assert.strictEqual(read.readableErrored, null);
assert.strictEqual(read.errored, null);
assert.strictEqual(read.destroyed, true);
}

Expand All @@ -32,7 +32,7 @@ const assert = require('assert');
}));

read.destroy(expected);
assert.strictEqual(read.readableErrored, expected);
assert.strictEqual(read.errored, expected);
assert.strictEqual(read.destroyed, true);
}

Expand Down

0 comments on commit 340b770

Please sign in to comment.