-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
express v5 beta support #1249
express v5 beta support #1249
Conversation
@@ -146,6 +146,7 @@ | |||
"eslint-plugin-mocha": "^10.1.0", | |||
"eslint-plugin-monorepo-cop": "^1.0.2", | |||
"express": "^4.19.2", | |||
"express-beta": "npm:express@^5.0.0-beta.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We encountered an ERESOLVE
error while resolving [email protected]
due to a version conflict with Express. Specifically:
[email protected]
requiresexpress@^4.17.1
.
The version of Express required by [email protected]
conflicts with the beta version of Express we are using. To address this, I am using express-beta
to avoid the dependency conflict.
2095af0
to
cf1787a
Compare
@@ -74,7 +74,7 @@ app.delete('/received/spans', (req, res) => { | |||
|
|||
// With the exception of /heartbeat, the Lambda extension would forward all requests to the | |||
// back end (serverless-acceptor). This handler mimicks that behavior. | |||
app.all('*', (req, res) => { | |||
app.all('(.*)', (req, res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Express 5 beta, wildcard routes have been changed to use (.*) instead of *. For more details, see the migration guide and the commit on GitHub.
shimmer.wrap(express.Router, 'handle', shimExpress4Handle); | ||
shimmer.wrap(express.Router, 'use', shimExpress4Use); | ||
} | ||
|
||
if (express.Router && express.Router.prototype) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The routing logic has been refactored to use the router module instead of a locally defined one. The methods to capture uncaught errors are now on the prototype of express.Router
. This ensures the code correctly wraps and intercepts the handle
and use
methods in Express 5 beta for error capturing.
reference expressjs/express@cec5780
'incoming-request': { | ||
body: req.body | ||
body: req.body ? req.body : {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The req.body is no longer always initialized to {} as seen in commit af341b0
Here we are expecting an object in the test case, earlier we are getting an empty object but now its undefined.
@@ -210,7 +210,8 @@ function verifySpans(spans, appControls) { | |||
// EXIT www.example.com | |||
// 2 x express middleware, 1 x request handler | |||
// 1 x tlc connect, 1 x tls connect | |||
expectExactlyNMatching(spans, 6, [ | |||
// TODO: middleware spans are not collected when migrating to express v5 beta. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Middleware initialization was removed in commit 78e5054.
- Middleware query functionality was removed in commit dcc4eaa.
The otel middleware spans are missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats I guess because Opentelemetry does not support Express v5 beta yet or?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, they are not yet added support for express v5 beta, see supported versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay as the exporter is getting deprecated anyway, we don't care that much.
Closing this PR, as https://github.com/instana/nodejs/pull/1261/files already merged. |
Express has been preparing for a major release (v5) for some time now, and they have already released several beta versions, including 5.0.0-beta.3.
For more details on migrating to Express v5, please refer to the migration guide.
This PR does not consider any of the breaking changes listed; it simply updates the version to the latest beta to see our tests
This PR is intended to test if our current setup works correctly with the latest beta version 5.0.0-beta.3 and to analyze the changes required for updating to v5.
At present, the npm install fails when we directly update Express to the beta version in our repo, due to the dependency with
apollo-server-express
package. To address this, I have kept the existing Express version and installed the beta version alongside it asexpress-beta
.Impact on our Tests
- Middleware query functionality was removed in commit dcc4eaa.
req.body
is no longer always initialized to{}
as seen in commit af341b0.req.body
beingundefined
rather than{}
.http.error
is not traced seerouter
module was used for routing instead of the previous implementation in Express, as seen in commit cec5780.app.all('*')
is not supported(*)
is no longer valid and must be written as(.*)
, for example app.all('(.*)'.(.*)
instead of*
. Special*
path segment behavior removed. see expressjs/express@1574925Tasks
Post-Release Considerations for v5
Refs
INSTA-12542
INSTA-12541
Track express v5 updates in expressjs/discussions#233