Skip to content

Commit

Permalink
fixup: TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed Jan 4, 2020
1 parent 4c7193e commit 9750a0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/internal/streams/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ function destroy(err, cb) {
const r = this._readableState;
const w = this._writableState;

// TODO(ronag): readable & writable = false?

if (err) {
if (w) {
w.errored = true;
Expand All @@ -16,8 +18,6 @@ function destroy(err, cb) {
}
}

// TODO(ronag): readable & writable = false?

if ((w && w.destroyed) || (r && r.destroyed)) {
if (cb) {
cb(err);
Expand Down Expand Up @@ -131,6 +131,8 @@ function errorOrDestroy(stream, err) {
const r = stream._readableState;
const w = stream._writableState;

// TODO(ronag): readable & writable = false?

if ((r && r.autoDestroy) || (w && w.autoDestroy))
stream.destroy(err);
else if (err) {
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-stream-readable-error-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

const common = require('../common');
const { Readable } = require('stream');
const assert = require('assert');

{
const r = new Readable({ read() {} });

r.on('data', common.mustCall());
r.on('end', common.mustNotCall());
r.on('data', common.mustCall());
r.on('error', common.mustCall());
r.push('asd');
r.push(null);
Expand Down

0 comments on commit 9750a0b

Please sign in to comment.