Skip to content

Commit 902a0d5

Browse files
author
Luca Forstner
committed
.
1 parent 928e1a3 commit 902a0d5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/nextjs/src/client/clientNormalizationIntegration.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ export const nextjsClientStackFrameNormalizationIntegration = defineIntegration(
88
const rewriteFramesInstance = rewriteFramesIntegration({
99
// Turn `<origin>/<path>/_next/static/...` into `app:///_next/static/...`
1010
iteratee: frame => {
11+
// A filename starting with the local origin and not ending with JS is most likely JS in HTML which we do not want to rewrite
12+
if (frame.filename?.startsWith(windowOrigin) && !frame.filename.endsWith('.js')) {
13+
return frame;
14+
}
15+
1116
if (assetPrefix) {
1217
if (frame.filename?.startsWith(assetPrefix)) {
1318
frame.filename = frame.filename.replace(assetPrefix, 'app://');
@@ -25,13 +30,13 @@ export const nextjsClientStackFrameNormalizationIntegration = defineIntegration(
2530

2631
// We need to URI-decode the filename because Next.js has wildcard routes like "/users/[id].js" which show up as "/users/%5id%5.js" in Error stacktraces.
2732
// The corresponding sources that Next.js generates have proper brackets so we also need proper brackets in the frame so that source map resolving works.
28-
if (frame.filename?.startsWith('app:///_next')) {
33+
if (frame.filename?.includes('/_next')) {
2934
frame.filename = decodeURI(frame.filename);
3035
}
3136

3237
if (
3338
frame.filename?.match(
34-
/^app:\/\/\/_next\/static\/chunks\/(main-|main-app-|polyfills-|webpack-|framework-|framework\.)[0-9a-f]+\.js$/,
39+
/\/_next\/static\/chunks\/(main-|main-app-|polyfills-|webpack-|framework-|framework\.)[0-9a-f]+\.js$/,
3540
)
3641
) {
3742
// We don't care about these frames. It's Next.js internal code.

0 commit comments

Comments
 (0)