Skip to content

fix: propagate errors from async trusted callback#405

Open
Nadav0077 wants to merge 1 commit intofastify:mainfrom
Nadav0077:fix/trusted-promise-rejection
Open

fix: propagate errors from async trusted callback#405
Nadav0077 wants to merge 1 commit intofastify:mainfrom
Nadav0077:fix/trusted-promise-rejection

Conversation

@Nadav0077
Copy link
Copy Markdown

@Nadav0077 Nadav0077 commented Apr 17, 2026

What this PR does

When a user supplied trusted callback returns a rejected promise, the rejection was silently dropped. .then(...) had no onRejected handler, so:

  • steed.waterfall's final callback was never invoked and the request hung.
  • The rejection surfaced as an unhandledRejection on the Node process.

Fix

Pass the onRejected handler to .then(...) so the error flows to the waterfall's terminal callback, matching the behavior of every other step.

Test

Added Trusted token, async verification rejects in test/jwt.test.js. It registers a trusted callback that returns Promise.reject(new Error('boom')) and asserts the error reaches the route handler (status 500, message === 'boom'). The test fails on main and passes with the fix.

Checklist

  • run npm run test && npm run benchmark --if-present
  • tests and/or benchmarks are included
  • documentation is changed or added (no API or doc change, purely a bug fix)
  • commit message and code follows the Developer's Certification of Origin
    and the Code of conduct

Copy link
Copy Markdown
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants