Skip to content

stream: readableDidRead if data has been read - #39543

Closed
ronag wants to merge 1 commit into
nodejs:masterfrom
nxtedition:readable-did-read
Closed

stream: readableDidRead if data has been read#39543
ronag wants to merge 1 commit into
nodejs:masterfrom
nxtedition:readable-did-read

Conversation

@ronag

@ronagronag commented Jul 27, 2021

Copy link
Copy Markdown
Member

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.

@ronagronag added the stream Issues and PRs related to the stream subsystem. label Jul 27, 2021
@ronag
ronag requested a review from mcollinaJuly 27, 2021 10:30
@ronagronag mentioned this pull request Jul 27, 2021
@ronag

Copy link
Copy Markdown
MemberAuthor

@nodejs/streams

@ronag

Copy link
Copy Markdown
MemberAuthor

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

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

ronag commented Jul 29, 2021

Copy link
Copy Markdown
MemberAuthor

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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ciPRs that need a full CI run.streamIssues and PRs related to the stream subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@ronag@nodejs-github-bot