-
Notifications
You must be signed in to change notification settings - Fork 30k
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
http2: fix ping callback #20311
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
6202d98
Compare
@nodejs/http @nodejs/http2 PTAL |
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.
Passing the payload is intentional here as that is what is used to correlate. I'm -1 to removing it.
@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. |
function pingCallback(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); |
To me this is very surprising to rely on any arguments if an error was returned. Any other opinions @nodejs/http2 @nodejs/tsc? |
As long as it’s documented this way, what are the issues with providing more information than just the error? |
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? |
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
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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 <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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