-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(nextjs): Take pageExtensions
option into account for auto instrumentation
#5881
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const BasicPage = (): JSX.Element => ( | ||
<h1> | ||
This page simply exists to test the compatibility of Next.js' `pageExtensions` option with our auto wrapping | ||
process. This file should be turned into a page by Next.js and our webpack loader should process it. | ||
</h1> | ||
); | ||
|
||
export async function getServerSideProps() { | ||
return { props: { data: '[some getServerSideProps data]' } }; | ||
} | ||
|
||
export default BasicPage; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This page simply exists to test the compatibility of Next.js' `pageExtensions` option with our auto wrapping | ||
process. This file should not be turned into a page by Next.js and our webpack loader also shouldn't process it. | ||
This page should not contain valid JavaScript. | ||
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we test the negative here in some way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I figured that this already is testing the negative - not really by having a dedicated test, but rather by not crashing when such a file is provided. We could theoretically try and open this page and wait for a 404 but at that point, I feel like we're testing Next.js itself. Did you have something else in mind? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I guess it would cause the build to fail if we tried to wrap it, wouldn't it? Okay, I think we're good here, thanks. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const assert = require('assert'); | ||
|
||
const { sleep } = require('../utils/common'); | ||
const { getAsync, interceptTracingRequest } = require('../utils/server'); | ||
|
||
module.exports = async ({ url: urlBase, argv }) => { | ||
const url = `${urlBase}/customPageExtension`; | ||
|
||
const capturedRequest = interceptTracingRequest( | ||
{ | ||
contexts: { | ||
trace: { | ||
op: 'http.server', | ||
status: 'ok', | ||
}, | ||
}, | ||
transaction: '/customPageExtension', | ||
transaction_info: { | ||
source: 'route', | ||
changes: [], | ||
propagations: 0, | ||
}, | ||
type: 'transaction', | ||
request: { | ||
url, | ||
}, | ||
}, | ||
argv, | ||
'tracingServerGetServerSidePropsCustomPageExtension', | ||
); | ||
|
||
await getAsync(url); | ||
await sleep(250); | ||
|
||
assert.ok(capturedRequest.isDone(), 'Did not intercept expected request'); | ||
}; |
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.
m: we don't have to set a default here?
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 mean it is always passed in very explicitly (see
webpack.ts
). Would it make sense to have another default here in your opinion?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.
Ahhh ok my bad didn't see how the types were linked up - with
LoaderOptions
it makes sense now.