Skip to content

http2: fix ping callback - #20311

Closed
BridgeAR wants to merge 2 commits into
nodejs:masterfrom
BridgeAR:fix-http2-ping-callback
Closed

http2: fix ping callback#20311
BridgeAR wants to merge 2 commits into
nodejs:masterfrom
BridgeAR:fix-http2-ping-callback

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.

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

@nodejs-github-botnodejs-github-bot added dont-land-on-v4.x http2 Issues or PRs related to the http2 subsystem. labels Apr 26, 2018
@BridgeAR

BridgeAR commented Apr 26, 2018

Copy link
Copy Markdown
MemberAuthor

In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
@BridgeAR
BridgeARforce-pushed the fix-http2-ping-callback branch from 56e627b to 6202d98CompareApril 26, 2018 11:21
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@nodejs/http @nodejs/http2 PTAL

@jasnelljasnell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Passing the payload is intentional here as that is what is used to correlate. I'm -1 to removing it.

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

@jasnell can you please elaborate? IMO this is against the default Node.js callback standard. In case of an error we normally only return the error and nothing else.

@jasnell

Copy link
Copy Markdown
Member
functionpingCallback(err,duration,payload){if(err){console.log(`Ping with payload "${payload.toString()}" failed`);}else{console.log(`Ping with payload "${payload.toString()}" succeeded with duration ${duration}`);}}session.ping(Buffer.from('12345678'),pingCallback);session.ping(Buffer.from('87654321'),pingCallback);

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

To me this is very surprising to rely on any arguments if an error was returned.

Any other opinions @nodejs/http2 @nodejs/tsc?

@addaleax

Copy link
Copy Markdown
Member

As long as it’s documented this way, what are the issues with providing more information than just the error?

@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Somewhat related: #20335

The documentation states:

The callback will be invoked with three arguments: an error argument that will be null if the PING was successfully acknowledged, a duration argument that reports the number of milliseconds elapsed since the ping was sent and the acknowledgment was received, and a Buffer containing the 8-byte PING payload.

The payload will be undefined in case of an error and there is no ack, so there should also not be a elapsed time, but the time is actually returned in case of an error. I do not even know what the returned time should now stand for and that seems like a bug to me.

Aside from that I expect all Node.js callbacks to always only return the error in an error case. Otherwise it seems like Schrödinger's cat to me. You get some results but also an error. What should you now work with?

@BridgeARBridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 27, 2018

@mcollinamcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

BridgeAR added a commit to BridgeAR/node that referenced this pull request Apr 29, 2018
In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
BridgeAR added a commit to BridgeAR/node that referenced this pull request Apr 29, 2018
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@BridgeAR

Copy link
Copy Markdown
MemberAuthor

Landed in bb546ac and 29cddb4

MylesBorins pushed a commit that referenced this pull request May 4, 2018
In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
PR-URL: #20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
MylesBorins pushed a commit that referenced this pull request May 4, 2018
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
PR-URL: #20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@MylesBorinsMylesBorins mentioned this pull request May 8, 2018
kjin pushed a commit to kjin/node that referenced this pull request Aug 23, 2018
In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
kjin pushed a commit to kjin/node that referenced this pull request Aug 23, 2018
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
kjin pushed a commit to kjin/node that referenced this pull request Sep 11, 2018
In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
kjin pushed a commit to kjin/node that referenced this pull request Sep 11, 2018
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
kjin pushed a commit to kjin/node that referenced this pull request Sep 19, 2018
In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
kjin pushed a commit to kjin/node that referenced this pull request Sep 19, 2018
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
kjin pushed a commit to kjin/node that referenced this pull request Oct 16, 2018
In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
kjin pushed a commit to kjin/node that referenced this pull request Oct 16, 2018
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
PR-URL: nodejs#20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
BethGriggs pushed a commit that referenced this pull request Oct 17, 2018
In case there was no ack, the callback would have returned
more than the error as return value. This makes sure that is not
the case anymore.
Backport-PR-URL: #22850
PR-URL: #20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
BethGriggs pushed a commit that referenced this pull request Oct 17, 2018
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
Backport-PR-URL: #22850
PR-URL: #20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
@BethGriggsBethGriggs mentioned this pull request Oct 30, 2018
@BridgeAR
BridgeAR deleted the fix-http2-ping-callback branch January 20, 2020 11:32
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.http2Issues or PRs related to the http2 subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@BridgeAR@jasnell@addaleax@mcollina@trivikr@nodejs-github-bot