quic: add proper error codes & messages for QUIC failures#63198
Conversation
|
Review requested:
|
31b4709 to
aefee4f
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #63198 +/- ##
==========================================
- Coverage 90.32% 90.29% -0.03%
==========================================
Files 730 730
Lines 234671 234825 +154
Branches 43946 43956 +10
==========================================
+ Hits 211965 212043 +78
- Misses 14423 14492 +69
- Partials 8283 8290 +7
🚀 New features to boost your workflow:
|
Ethan-Arrowood
left a comment
There was a problem hiding this comment.
this is a great change.
Ethan-Arrowood
left a comment
There was a problem hiding this comment.
this is a great change.
40eebfd to
60b6e3b
Compare
|
Updated to use bindingdata, rebased and force pushed because we need to update the test from #63193 (just merged) as well since that asserted on the error message. |
Qard
left a comment
There was a problem hiding this comment.
Is there some reason you're undid the use of the existing core errors system? Shouldn't we be keeping that?
| function makeQuicError(code, prefix, type, errorCode, reason, errorName) { | ||
| const err = new QuicError( | ||
| quicErrorMessage(prefix, errorCode, reason, errorName), | ||
| { errorCode, code, type }); | ||
| if (reason) err.reason = reason; | ||
| if (errorName) err.errorName = errorName; | ||
| return err; | ||
| } |
There was a problem hiding this comment.
Should we not keep the same error construction mechanism as the others? We lose a bunch of things by not using that. Not sure we should be taking these out of the global errors set.
There was a problem hiding this comment.
This was a suggestion here, changed here.
We still use standard error codes, but we use a single QuicError class instead of the standard construction of per-code error classes: https://github.com/nodejs/node/blob/main/doc/api/quic.md#class-quicerror. This error class is used by users as well to control QUIC error behaviour, and this approach gives us consistent errors for every kind of failure at the protocol level. I don't feel strongly about it myself, but it seemed like a reasonable suggestion and having a single QUIC error class is tidy.
What do we lose by not using the standard error mechanism vs this setup?
There was a problem hiding this comment.
We lose the hideStackFrames logic, which means we'll see a bunch more internals things in stack traces here which we might not want to surface, like every validator gains a stack line without this. I'm not against this change, but just want to be sure that special-casing this is acceptable.
There was a problem hiding this comment.
In this case, I think the previous code didn't do this either - our validators do hide internal stack traces, but AFAICT the normal error code definitions don't do this unless you use HideStackFramesError explicitly.
It is easy to do though, and I agree it'd be a nice improvement - I've just pushed a commit that adds ErrorCaptureStackTrace(err, makeQuicError) here, which will omit these internal bits from the stack in the same way. This mirrors the equivalent setup for custom errors elsewhere like
Lines 350 to 363 in 92f48f4
Is that what you were looking for?
Signed-off-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
Signed-off-by: Tim Perry <pimterry@gmail.com>
Qard
left a comment
There was a problem hiding this comment.
Linter seems to be complaining, but otherwise LGTM.
Move error paths added on main onto the new QuicError flow here, and fix the error code in CheckStreamIdleTimeout, which was incorrect and so failed validation.
6adb825 to
c5bd305
Compare
Yeah, linting passed in isolation but failed on the merge commit due to new errors added elsewhere. I've now rebased, fixed the conflicting changes so everything'll hopefully pass, and force pushed. If you have a second to re-review @Qard I'd appreciate it! 🙏 Thanks |
|
Landed in e1ae3a5 |
This wraps QUIC errors, providing useful error codes and messages for the defined error code cases from both OpenSSL and ngtcp2.
Before this, QUIC errors looked like:
Now they look like: