You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix ExpressAdapter to accept Express app directly (#504)
## Summary
- **Fix `ERR_HTTP_HEADERS_SENT`** when passing an `http.Server` that
already has an Express app attached — the adapter no longer creates a
second Express app in that scenario
- `ExpressAdapter` constructor now accepts `http.Server |
express.Application | undefined`:
- **Express app passed**: uses it directly - assumes the http server is
being managed by the user directly.
- **http.Server passed**: creates internal Express app, attaches to
server (existing behavior)
- **Nothing passed**: creates both (existing behavior)
- Updated Express example to pass the Express app directly (the
recommended pattern)
The original `http.Server`-only constructor was designed to match the
`HttpPlugin`'s capabilities, but it led users into a trap: passing
`http.createServer(app)` caused the adapter to attach a second Express
app to the same server, resulting in double request handling. Accepting
the Express app directly is the natural fix. Ideally, we should probably
just not accept an http server and just accept an existing express app.
If someone is managing an express app outside, they can continue doing
that, and they should be responsible for handling the http server too.
Fixes#503
## Test plan
- [x] Existing `express-adapter` tests pass (9/9)
- [x] New test: passing an Express app works for both custom routes and
adapter-registered routes
- [x] Manual: verify Express example compiles and runs correctly
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
0 commit comments