Skip to content

Commit af52ef0

Browse files
authored
Instrumentation + Sentry (#38)
1 parent 586372a commit af52ef0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

pages/aws/common_issues.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,39 @@ If you are refreshing a dynamic/static route or going to that route directly fro
6262
This can also happen in app router when a client navigates via NextJS `<Link>` component.
6363

6464
The issue might be that your having a folder or file in your `public` directory with an overlapping between the name and your route. In this case, you should rename that to something else.
65+
66+
67+
#### `cannot find module './chunks/xxxx.js'` error
68+
69+
Dynamic imports in `instrumentation.ts` will cause this error at runtime. Remove dynamic imports to resolve.
70+
71+
#### Sentry server side setup
72+
73+
The config recommended by Sentry docs uses dynamic imports in `instrumentation.ts`, which causes the above error.
74+
75+
Here's a working Sentry config which resolves the error:
76+
77+
`instrumentation.ts`
78+
```typescript
79+
import * as Sentry from '@sentry/nextjs';
80+
import { initSentry } from '../sentry.server.config';
81+
82+
export const onRequestError = Sentry.captureRequestError;
83+
84+
export async function register() {
85+
initSentry(process.env.NEXT_RUNTIME as 'nodejs' | 'edge');
86+
}
87+
```
88+
89+
`sentry.server.config.ts`
90+
```typescript
91+
import * as Sentry from '@sentry/nextjs';
92+
93+
export const initSentry = (runtime: 'nodejs' | 'edge') => {
94+
Sentry.init({
95+
dsn: 'https://...',
96+
97+
//...rest of your config
98+
});
99+
};
100+
```

0 commit comments

Comments
 (0)