Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: unify writableErrored and readableErrored #40799

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ added:
Number of times [`writable.uncork()`][stream-uncork] needs to be
called in order to fully uncork the stream.

##### `writable.writableErrored`
##### `writable.errored`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs changes: entries?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These props have never made it to any release... is that really necessary?


<!-- YAML
added:
Expand Down Expand Up @@ -1377,7 +1377,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 @@ -1239,7 +1239,7 @@ ObjectDefineProperties(Readable.prototype, {
}
},

readableErrored: {
errored: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do the readableErrored and writableErrored need to go through a deprecation cycle first? Those should likely be runtime deprecated aliases, yes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. They haven’t been in any release.

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 @@ -854,7 +854,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