Support Express 5 stable and fix async handler errors - #10
Merged
Conversation
- Bump peerDependencies and devDependencies from `^5.0.0-alpha.1/6` to `^5.0.0` to target the Express 5 stable release. - Make `wrapMiddleware` async and await the user handler so that rejected promises from async WebSocket handlers are caught by the try/catch and forwarded to `next(err)` rather than becoming silent unhandled rejections. Backwards-compatible with Express 4. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
alecgibson
force-pushed
the
express-5-stable-compat
branch
from
March 19, 2026 13:18
5f13a4d to
1997ce9
Compare
alecgibson
marked this pull request as ready for review
March 19, 2026 13:18
There was a problem hiding this comment.
Pull request overview
This PR updates the package to support stable Express 5 and ensures async WebSocket handlers have their rejected promises/errors forwarded into Express error handling (instead of becoming unhandled rejections), while maintaining Express 4 compatibility via next(err).
Changes:
- Bump Express peer/dev dependency ranges from Express 5 alpha to stable
^5.0.0. - Make
wrapMiddlewareasyncandawaitthe user-supplied handler to catch async rejections and forward them tonext(err). - Update the package version to
5.0.0-reedsy-5.1.0.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/wrap-middleware.js |
Awaits user middleware to catch async errors and forward to next(err). |
package.json |
Updates Express peer/dev dependency ranges and bumps package version. |
Comments suppressed due to low confidence (1)
package.json:32
peerDependencies.expressis expanded to include Express 5, butengines.nodestill claims support for Node >=4.5.0, which cannot run this package as ESM ("type": "module") and also won’t support the newly addedasync/awaitusage. Please update theengines.noderange to reflect the actual minimum supported Node version (and, if applicable, align it with the Node version used in CI via.nvmrc).
"express": "^4.0.0 || ^5.0.0"
},
"engines": {
"node": ">=4.5.0"
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -1,10 +1,10 @@ | |||
| export function wrapMiddleware(middleware) { | |||
| return (req, res, next) => { | |||
| return async (req, res, next) => { | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
peerDependenciesanddevDependenciesfrom the alpha Express 5 range (^5.0.0-alpha.1/^5.0.0-alpha.6) to the stable^5.0.0.wrapMiddlewareasyncandawaits the user-supplied handler, so rejected promises from async WebSocket handlers are caught by thetry/catchand forwarded tonext(err)instead of becoming silent unhandled rejections. This also lets Express 5's own promise-handling layer catch any uncaught rejections from the wrapper itself.next(err), not relying on Express 5 promise handling.Test plan
npm install— no peer dependency conflicts withexpress@5.node examples/simple.js) against Express 5 and confirm WebSocket connections work.🤖 Generated with Claude Code