Uh oh!
There was an error while loading. Please reload this page.
http2: fix ping callback - #20311
Conversation
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).
56e627b to
6202d98CompareBridgeAR
commented
Apr 26, 2018
@nodejs/http @nodejs/http2 PTAL |
jasnell
left a comment
There was a problem hiding this comment.
Passing the payload is intentional here as that is what is used to correlate. I'm -1 to removing it.
BridgeAR
commented
Apr 26, 2018
@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
commented
Apr 26, 2018
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
commented
Apr 26, 2018
To me this is very surprising to rely on any arguments if an error was returned. Any other opinions @nodejs/http2 @nodejs/tsc? |
addaleax
commented
Apr 26, 2018
As long as it’s documented this way, what are the issues with providing more information than just the error? |
BridgeAR
commented
Apr 27, 2018
Somewhat related: #20335 The documentation states: The payload will be undefined in case of an error and there is no 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? |
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>
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
commented
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: #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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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), orvcbuild test(Windows) passes