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: async iterator destroy compat #29176

Closed
wants to merge 1 commit into from

Conversation

@ronag
Copy link
Contributor

commented Aug 17, 2019

destroy with callback can achieved using destroy

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
@ronag

This comment has been minimized.

Copy link
Contributor Author

commented Aug 17, 2019

@mcollina is there a reason why it's not done like this instead?

@mcollina
Copy link
Member

left a comment

I’m ok in changing the async iterator. I’m -1 in changing destroy().
The callback in destroy predates adding finished to node core.

@ronag

This comment has been minimized.

Copy link
Contributor Author

commented Aug 17, 2019

How about we keep the destroy callback but consider it deprecated? So we don’t use it in core. A comment maybe?

@ronag

This comment has been minimized.

Copy link
Contributor Author

commented Aug 17, 2019

The biggest issue I have with this is that it's undocumented and monkey patched destroy will break in unexpected ways:

  • async iterator return.
  • monkey patching destroy on fs streams.

There are a few destroy in core that does not provide the cb functionality.

  • IncomingMessage
  • OutgoingMessage
  • ClientRequest
  • Worker (not a stream)
  • Agent (not a stream)

An alternative is to make it documented and part of the public API? Also, I wouldn't mind fixing the once that are streams.

@ronag ronag force-pushed the nxtedition:stream-destroy-cb branch from a062e90 to 4e76538 Aug 17, 2019

@mcollina

This comment has been minimized.

Copy link
Member

commented Aug 17, 2019

The callback property was added because it was needed somewhere in core. Maybe that has changed somehow, but I would rather wait before calling it deprecated.

Fixing the stream iterator thing is important anyway, good spot.

@ronag ronag force-pushed the nxtedition:stream-destroy-cb branch 5 times, most recently from 81f38d2 to f168368 Aug 17, 2019

@mcollina

This comment has been minimized.

Copy link
Member

commented Aug 17, 2019

Can you add a test with an overridden destroy with no callback?

@mcollina

This comment has been minimized.

Copy link
Member

commented Aug 17, 2019

You might want to change the name of the PR and the commit message.

@ronag

This comment has been minimized.

Copy link
Contributor Author

commented Aug 17, 2019

Added test

@ronag ronag force-pushed the nxtedition:stream-destroy-cb branch from f168368 to 9b36299 Aug 17, 2019

@ronag ronag changed the title stream: remove non public arg from public destroy API stream: async iterator destroy compat Aug 17, 2019

@ronag

This comment has been minimized.

Copy link
Contributor Author

commented Aug 17, 2019

Messages fixed

@ronag ronag force-pushed the nxtedition:stream-destroy-cb branch from 9b36299 to 81118d4 Aug 17, 2019

@ronag

This comment has been minimized.

Copy link
Contributor Author

commented Aug 17, 2019

The callback property was added because it was needed somewhere in core

Yep. I can see it now. Classes that inherit from streams use it sometimes. But it doesn't ever seem to be used outside of the implementation (except for the case with this PR).

We might want to consider refactoring that and calling the method something else hidden behind a symbol.

@ronag ronag referenced this pull request Aug 17, 2019
0 of 5 tasks complete
@ronag

This comment has been minimized.

Copy link
Contributor Author

commented Aug 17, 2019

Created a follow up issue #29180

@ronag ronag force-pushed the nxtedition:stream-destroy-cb branch 7 times, most recently from e08ccc1 to 71c4984 Aug 17, 2019

lib/internal/streams/async_iterator.js Outdated Show resolved Hide resolved
const stream = this[kStream];

// TODO(ronag): Remove this check once finished() handles
// already destroyed streams.

This comment has been minimized.

Copy link
@mcollina

mcollina Aug 17, 2019

Member

Isn’t that part of another PR?

This comment has been minimized.

Copy link
@ronag

ronag Aug 17, 2019

Author Contributor

yes, put this as blocked and wait for that first?

This comment has been minimized.

Copy link
@ronag

ronag Aug 17, 2019

Author Contributor

it's not exactly the same, #28748 does not check readableEnded which will break this for streams that do not emit 'close' after 'end'. Maybe #28748 should be updated? I'm not sure... I prefer to do this in steps...

@ronag ronag force-pushed the nxtedition:stream-destroy-cb branch from 71c4984 to e1290f2 Aug 17, 2019

stream: async iterator destroy compat
async iterator should not depend on internal API for better compat
with streamlike objects.

@ronag ronag force-pushed the nxtedition:stream-destroy-cb branch from e1290f2 to 98fcb56 Aug 17, 2019

@mcollina
Copy link
Member

left a comment

LGTM

@mcollina mcollina requested review from BridgeAR, addaleax and benjamingr Aug 22, 2019

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@Trott Trott added the author ready label Aug 23, 2019

mcollina added a commit that referenced this pull request Aug 23, 2019
stream: async iterator destroy compat
async iterator should not depend on internal API for better compat
with streamlike objects.

PR-URL: #29176
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@mcollina

This comment has been minimized.

Copy link
Member

commented Aug 23, 2019

Landed in 4e188b3

@mcollina mcollina closed this Aug 23, 2019

ronag added a commit to nxtedition/node that referenced this pull request Aug 23, 2019
stream: async iterator destroy compat
async iterator should not depend on internal API for better compat
with streamlike objects.

PR-URL: nodejs#29176
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@ronag ronag referenced this pull request Aug 26, 2019
4 of 4 tasks complete
BridgeAR added a commit that referenced this pull request Sep 3, 2019
stream: async iterator destroy compat
async iterator should not depend on internal API for better compat
with streamlike objects.

PR-URL: #29176
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@BridgeAR BridgeAR referenced this pull request Sep 3, 2019
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
stream: async iterator destroy compat
async iterator should not depend on internal API for better compat
with streamlike objects.

PR-URL: nodejs#29176
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
JeniaBR added a commit to JeniaBR/node that referenced this pull request Sep 11, 2019
stream: async iterator destroy compat
async iterator should not depend on internal API for better compat
with streamlike objects.

PR-URL: nodejs#29176
Reviewed-By: Matteo Collina <matteo.collina@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
Projects
None yet
5 participants
You can’t perform that action at this time.