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: pass error on legacy destroy #43519

Merged
merged 2 commits into from
Jun 28, 2022

Conversation

greguz
Copy link
Contributor

@greguz greguz commented Jun 21, 2022

While looking at readable-stream source, I've found a possible missed argument while emitting an error toward legacy streams.

  • Include tests for any bug fixes or new features.
  • Update documentation if relevant.
  • Ensure that make lint passes.
  • Ensure that make -j4 test (UNIX), or vcbuild test (Windows) passes.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/streams

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jun 21, 2022
@mscdex
Copy link
Contributor

mscdex commented Jun 21, 2022

This needs a test

@greguz greguz force-pushed the streams-legacy-error branch from f629df5 to 10be672 Compare June 21, 2022 10:37
@greguz greguz changed the title streams: pass error on legacy destroy stream: pass error on legacy destroy Jun 21, 2022
@greguz
Copy link
Contributor Author

greguz commented Jun 21, 2022

@mscdex I came out (about tests) with this:

test/parallel/test-stream-pipeline.js

{
  // Mimics a legacy stream without the .destroy method
  class LegacyWritable extends Stream {
    write(chunk, encoding, callback) {
      callback();
    }
  }

  const writable = new LegacyWritable();
  writable.on('error', common.mustCall((err) => {
    assert.deepStrictEqual(err, new Error('stop'));
  }));

  pipeline(
    Readable.from({
      [Symbol.asyncIterator]() {
        return {
          next() {
            return Promise.reject(new Error('stop'));
          }
        };
      }
    }),
    writable,
    common.mustCall((err) => {
      assert.deepStrictEqual(err, new Error('stop'));
    })
  );
}

I have to say that this is a very specific edge case. The only way to trigger the bug is to use either finished or compose functions provided by the stream subsystem in combination with not-so-standard stream instances.

Copy link
Member

@benjamingr benjamingr left a comment

Choose a reason for hiding this comment

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

The test looks fine (it's indeed an edge case but the test is needed to make sure we don't cause a regression in the future)

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@mcollina mcollina added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. and removed needs-ci PRs that need a full CI run. labels Jun 28, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Jun 28, 2022
@nodejs-github-bot nodejs-github-bot merged commit 51beb26 into nodejs:main Jun 28, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 51beb26

@greguz greguz deleted the streams-legacy-error branch July 1, 2022 19:13
targos pushed a commit that referenced this pull request Jul 12, 2022
PR-URL: #43519
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants