Skip to content

quic: add proper error codes & messages for QUIC failures#63198

Open
pimterry wants to merge 1 commit intonodejs:mainfrom
pimterry:fix-quic-error-codes
Open

quic: add proper error codes & messages for QUIC failures#63198
pimterry wants to merge 1 commit intonodejs:mainfrom
pimterry:fix-quic-error-codes

Conversation

@pimterry
Copy link
Copy Markdown
Member

@pimterry pimterry commented May 8, 2026

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:

// Application error with an explicit reason string:
Error [ERR_QUIC_APPLICATION_ERROR]: A QUIC application error occurred. 42n [client shutdown]
    at [kFinishClose] (node:internal/quic/quic:3505:22)
    at Session.onSessionClose (node:internal/quic/quic:679:31) {
  code: 'ERR_QUIC_APPLICATION_ERROR'
}

// All our internal errors:
Error [ERR_QUIC_TRANSPORT_ERROR]: A QUIC transport error occurred. 296n [undefined]
    at [kFinishClose] (node:internal/quic/quic:3502:22)
    at Session.onSessionClose (node:internal/quic/quic:679:31) {
  code: 'ERR_QUIC_TRANSPORT_ERROR'
}

Now they look like:

Error [ERR_QUIC_APPLICATION_ERROR]: QUIC application error 42: client shutdown
    at makeQuicError (node:internal/quic/quic:999:15)
    at [kFinishClose] (node:internal/quic/quic:3552:22)
    at Session.onSessionClose (node:internal/quic/quic:681:31) {
  code: 'ERR_QUIC_APPLICATION_ERROR',
  errorCode: 42n,
  type: 'application',
  reason: 'client shutdown'
}

Error [ERR_QUIC_TRANSPORT_ERROR]: QUIC transport error handshake failure (296)
    at makeQuicError (node:internal/quic/quic:988:15)
    at [kFinishClose] (node:internal/quic/quic:3534:22)
    at Session.onSessionClose (node:internal/quic/quic:681:31) {
  code: 'ERR_QUIC_TRANSPORT_ERROR',
  errorCode: 296n,
  type: 'transport',
  errorName: 'handshake failure'
}

@nodejs-github-bot
Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/quic

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels May 8, 2026
Signed-off-by: Tim Perry <pimterry@gmail.com>
@pimterry pimterry force-pushed the fix-quic-error-codes branch from 31b4709 to aefee4f Compare May 8, 2026 13:41
Comment thread lib/internal/quic/quic.js

function makeQuicError(ErrorClass, prefix, type, errorCode, reason, errorName) {
const err = new ErrorClass(
quicErrorMessage(prefix, errorCode, reason, errorName));
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.

We have the QuicError object, we should likely make use of it in here as well. The code can remain the same. No need to change it in this PR but for consistency, any error that includes the QUIC error code should use QuicError

Comment thread src/quic/data.cc
case NGTCP2_NO_VIABLE_PATH:
return "NO_VIABLE_PATH";
case NGTCP2_VERSION_NEGOTIATION_ERROR:
return "VERSION_NEGOTIATION_ERROR";
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.

Since this set is stable, we should just add them as strings on the quic BindingData to avoid having to create duplicate v8::String values.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.02%. Comparing base (9adddc5) to head (aefee4f).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63198      +/-   ##
==========================================
- Coverage   90.04%   90.02%   -0.02%     
==========================================
  Files         713      713              
  Lines      224926   224964      +38     
  Branches    42525    42526       +1     
==========================================
- Hits       202526   202523       -3     
- Misses      14180    14227      +47     
+ Partials     8220     8214       -6     
Files with missing lines Coverage Δ
lib/internal/errors.js 97.64% <100.00%> (ø)
lib/internal/quic/quic.js 100.00% <100.00%> (ø)

... and 36 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants