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: readableDidRead if data has been read #39543

Closed
wants to merge 1 commit into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Jul 27, 2021

Only readableDidRead if there actually has been data read.

We have a slight conflict of use case here:

  1. If user has intention of reading, e.g. used by http to know if it's safe to dump. (https://github.com/nodejs/node/blob/master/lib/_http_server.js#L805-L806)
  2. If user wants to know if data has been read and whether or not it is possible to get all data, for e.g. json parsing. (https://github.com/nodejs/node/pull/39520/files#diff-040c1f5a53844e600d40b33c4624f1fe39fcf2f8d62c76ca3fc5ea5442231469R1366-R1368)

1, If resume(), read(), pipe() has been called or 'data' or 'readable' listener exists.
2, If read() has returned data or 'end' or 'data' has been emitted.

Do we need two separate properties and if so what should they be called?

readableDidRead, readableDisturbed, readableUsed or readableReading?

If we only want/need one of them I would prefer 2.

@ronag ronag added the stream Issues and PRs related to the stream subsystem. label Jul 27, 2021
@ronag ronag requested a review from mcollina July 27, 2021 10:30
@ronag ronag mentioned this pull request Jul 27, 2021
@ronag
Copy link
Member Author

ronag commented Jul 27, 2021

@nodejs/streams

@ronag
Copy link
Member Author

ronag commented Jul 27, 2021

Actually, #39520 implements 2 as Readable.bodyUsed so maybe we don't need to do anything?

@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Jul 27, 2021
@ronag
Copy link
Member Author

ronag commented Jul 29, 2021

I'm probably good at leaving things as is and have bodyUsed as 2. Leaving this open for now for visibility. @nodejs/streams if you have seen this and have nothing further to add please just 👍 and I'll close this after a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-ci PRs that need a full CI run. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants