-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
src,stream: improve DoWrite() and Write() #44434
Conversation
Review requested:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you include a test?
@@ -2372,8 +2372,7 @@ int Http2Stream::DoWrite(WriteWrap* req_wrap, | |||
CHECK_NULL(send_handle); | |||
Http2Scope h2scope(this); | |||
if (!is_writable() || is_destroyed()) { | |||
req_wrap->Done(UV_EOF); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RafaelGSS After investigation, I find out that this if
statement should be turned to an assertion. Because the JS code make sure that whenever we do a write on a stream, the stream is writable and not destroyed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing it to an assertion (CHECK
) will crash the application whenever someone tries to write in a destroyed stream, is that expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JS code in /lib will not let this happens. Without misusing the internals, the case that captured by this if
can not happen. If you insist keeping this if
, then apparently, this function should return an error code immediately and never invoke the cb, because this is what every asynchronous API should do in case an immediate failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that happens when misusing the internals, adding the CHECK
make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This comment was marked as outdated.
This comment was marked as outdated.
https://ci.nodejs.org/job/node-test-binary-windows-js-suites/16604/
The first one failed on many other CI, either, as you can see in nodejs/reliability#368. The second one fails rarely, maybe triggered by some concurrency issue, more details in #44515 |
Hello, how should I move this PR forward? @mcollina |
Clarify StreamResource::DoWrite() interface definition. Fix error-prone Http2Stream::DoWrite(). Change StreamBase::Write() to allow caller to avoid inefficient write behavior.
Hi @ywave620, looks like those tests were fixed. Could you please rebase? |
28ab1e0
to
858972c
Compare
Commit Queue failed- Loading data for nodejs/node/pull/44434 ✔ Done loading data for nodejs/node/pull/44434 ----------------------------------- PR info ------------------------------------ Title src,stream: improve DoWrite() and Write() (#44434) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch ywave620:src-stream-improve -> nodejs:main Labels c++, lib / src, commit-queue-squash Commits 2 - src,stream: improve DoWrite() and Write() - src,stream: improve DoWrite() and Write() Committers 1 - rogertyang PR-URL: https://github.com/nodejs/node/pull/44434 Reviewed-By: Matteo Collina Reviewed-By: Stephen Belanger ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/44434 Reviewed-By: Matteo Collina Reviewed-By: Stephen Belanger -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - src,stream: improve DoWrite() and Write() ⚠ - src,stream: improve DoWrite() and Write() ℹ This PR was created on Mon, 29 Aug 2022 11:02:42 GMT ✔ Approvals: 2 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/44434#pullrequestreview-1091912155 ✔ - Stephen Belanger (@Qard): https://github.com/nodejs/node/pull/44434#pullrequestreview-1091998538 ⚠ GitHub cannot link the author of 'src,stream: improve DoWrite() and Write()' to their GitHub account. ⚠ Please suggest them to take a look at https://github.com/nodejs/node/blob/99b1ada/doc/guides/contributing/pull-requests.md#step-1-fork ⚠ GitHub cannot link the author of 'src,stream: improve DoWrite() and Write()' to their GitHub account. ⚠ Please suggest them to take a look at https://github.com/nodejs/node/blob/99b1ada/doc/guides/contributing/pull-requests.md#step-1-fork ✔ Last GitHub CI successful ℹ Last Full PR CI on 2022-10-06T16:58:57Z: https://ci.nodejs.org/job/node-test-pull-request/47105/ - Querying data for job/node-test-pull-request/47105/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/3205357558 |
@ywave620 could you please make sure that the email you use to commit is linked to your github account? Our tooling for landing PRs is failing.
|
@mcollina Done :). Please try again. |
Commit Queue failed- Loading data for nodejs/node/pull/44434 ✔ Done loading data for nodejs/node/pull/44434 ----------------------------------- PR info ------------------------------------ Title src,stream: improve DoWrite() and Write() (#44434) ⚠ Could not retrieve the email or name of the PR author's from user's GitHub profile! Branch ywave620:src-stream-improve -> nodejs:main Labels c++, lib / src, commit-queue-squash Commits 2 - src,stream: improve DoWrite() and Write() - src,stream: improve DoWrite() and Write() Committers 1 - rogertyang PR-URL: https://github.com/nodejs/node/pull/44434 Reviewed-By: Matteo Collina Reviewed-By: Stephen Belanger ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/44434 Reviewed-By: Matteo Collina Reviewed-By: Stephen Belanger -------------------------------------------------------------------------------- ⚠ Commits were pushed since the last review: ⚠ - src,stream: improve DoWrite() and Write() ⚠ - src,stream: improve DoWrite() and Write() ℹ This PR was created on Mon, 29 Aug 2022 11:02:42 GMT ✔ Approvals: 2 ✔ - Matteo Collina (@mcollina) (TSC): https://github.com/nodejs/node/pull/44434#pullrequestreview-1091912155 ✔ - Stephen Belanger (@Qard): https://github.com/nodejs/node/pull/44434#pullrequestreview-1091998538 ⚠ GitHub cannot link the author of 'src,stream: improve DoWrite() and Write()' to their GitHub account. ⚠ Please suggest them to take a look at https://github.com/nodejs/node/blob/99b1ada/doc/guides/contributing/pull-requests.md#step-1-fork ✔ Last GitHub CI successful ℹ Last Full PR CI on 2022-10-07T14:11:45Z: https://ci.nodejs.org/job/node-test-pull-request/47105/ - Querying data for job/node-test-pull-request/47105/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/3209456339 |
fix comment
@mcollina Sorry. It turns out that the email used in the latest commit is in bad format, I need to rewrite the author metadata. |
858972c
to
9719a8a
Compare
@mcollina No substantial change at all, only the commit email is modified, shall we skip the CI phase? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Our automated landing will complain if there are no CI run for the commit. |
@mcollina CI done. Please help landing this :) |
Landed in 78d280a |
Clarify StreamResource::DoWrite() interface definition. Fix error-prone Http2Stream::DoWrite(). Change StreamBase::Write() to allow caller to avoid inefficient write behavior. PR-URL: #44434 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
StreamBase::Write()
callsStreamResource::DoTryWrite()
andStreamResource::DoWrite()
to do the job.However the interface definition of
StreamResource::DoWrite()
is error-prone or at least confusing, which I guess leads to an wrong(but no effect fortunately) override,Http2Stream::DoWrite()
. This PR takes care of these two issues and make theStreamBase::WriteString()
more efficent in the case where the underlying stream is too busy to receive more data.