diff --git a/pages/aws/common_issues.mdx b/pages/aws/common_issues.mdx index 0209efc..49c66e7 100644 --- a/pages/aws/common_issues.mdx +++ b/pages/aws/common_issues.mdx @@ -62,3 +62,39 @@ If you are refreshing a dynamic/static route or going to that route directly fro This can also happen in app router when a client navigates via NextJS `` component. 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. + + +#### `cannot find module './chunks/xxxx.js'` error + +Dynamic imports in `instrumentation.ts` will cause this error at runtime. Remove dynamic imports to resolve. + +#### Sentry server side setup + +The config recommended by Sentry docs uses dynamic imports in `instrumentation.ts`, which causes the above error. + +Here's a working Sentry config which resolves the error: + +`instrumentation.ts` +```typescript +import * as Sentry from '@sentry/nextjs'; +import { initSentry } from '../sentry.server.config'; + +export const onRequestError = Sentry.captureRequestError; + +export async function register() { + initSentry(process.env.NEXT_RUNTIME as 'nodejs' | 'edge'); +} +``` + +`sentry.server.config.ts` +```typescript +import * as Sentry from '@sentry/nextjs'; + +export const initSentry = (runtime: 'nodejs' | 'edge') => { + Sentry.init({ + dsn: 'https://...', + + //...rest of your config + }); +}; +```