GeezerVison is showing github.com — fix(nextjs): Support automatic instrumentation for app directory with custom page extensions by ziyadkhalil · Pull Request #12858 · getsentry/sentry-javascript
Conversation
ziyadkhalil
commented
Jul 10, 2024
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
This PR updates the regex and logic for detecting middleware, route handler, and server component files to support custom page extensions, such as middleware.custom.ts and route.custom.ts.
Changes Made
- Modified the
isRouteHandler function to use a regex that matches custom page extensions for route handler files.
- Modified the
isMiddlewareResource function to use a regex that matches custom page extensions for middleware files.
- Modified the
isServerComponent function to use a regex that matches custom page extensions for server component files.
- modified
hasGlobalErrorFile flag to account for custom page extensions
Testing
- Verified the updated regex matches route handlers and middleware files with standard and custom extensions.
- Added new cases for server loaders tests to cover route handler files
- Updated and passed all test cases.
- Added a duplicate e2e nextjs project with page extensions enabled and it passes all tests e2e(nextjs): add nextjs app dir project with page extensions #12864
Checklist
Please review and provide feedback. Thank you!
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
HagerDakroury reacted with hooray emoji
HagerDakroury reacted with heart emoji
millar and HagerDakroury reacted with rocket emoji
All reactions
-
🎉
1 reaction
-
❤️
1 reaction
-
🚀
2 reactions
ziyadkhalil
changed the title
fix(nextjs): Support automatic instrumentation for route handlers and…
fix(nextjs): Support automatic instrumentation for route handlers and middleware with custom page extensions
Jul 10, 2024
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sure! I'm not sure which test to update tho as to test this change we have to set the pageExtension option in next.config.js
Good question. I'll let the other sdk maintainers chime in here for this as I have no strong opinions
|
ziyadkhalil reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ziyadkhalil
changed the title
fix(nextjs): Support automatic instrumentation for route handlers and middleware with custom page extensions
fix(nextjs): Support automatic instrumentation for app directory with custom page extensions
Jul 10, 2024
|
@AbhiPrasad Great! I created another PR #12864 with the suggested solution and it was a great idea that made me notice that page extensions feature is not working for server components as well.
I updated this PR to enable instrumentation for server components as well.
It passes all the e2e tests in the other PR #12864
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
ziyadkhalil reacted with thumbs up emoji
Comment on lines
-174
to
-175
|
|
resourcePath: '/Users/Maisey/projects/squirrelChasingSimulator/src/app/nested/page.ts', // ts is not a valid file ending for pages in the app dir
|
|
|
expectedWrappingTargetKind: undefined,
|
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.
I checked and this is actually not true. It's just very uncommon because usually you have jsx in your pages.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
I am gonna merge this so that this is off your plate @ziyadkhalil. I will add tests as a follow-up.
|
ziyadkhalil reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced Aug 7, 2024
This was referenced Aug 9, 2024
This was referenced Aug 22, 2024
Reviewers
AbhiPrasad
Awaiting requested review from AbhiPrasad
1 more reviewer
lforst
lforst approved these changes
Reviewers whose approvals may not affect merge requirements
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|