From 1820c9edf8960bc9587de1a3ec2c9a6f6ce06b5c Mon Sep 17 00:00:00 2001
From: AndreyMay <51962295+AndreyMay@users.noreply.github.com>
Date: Sat, 14 Dec 2024 03:09:30 -0800
Subject: [PATCH 1/2] Instrumentation + Sentry
---
pages/aws/common_issues.mdx | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/pages/aws/common_issues.mdx b/pages/aws/common_issues.mdx
index 0209efc..490e72b 100644
--- a/pages/aws/common_issues.mdx
+++ b/pages/aws/common_issues.mdx
@@ -62,3 +62,35 @@ 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.
+
+
+#### Sentry does not work for api/server side + `cannot find module './chunks/3381.js'` error
+
+Sentry didn't work with the config recommended by Sentry docs which has `instrumentation.ts` with dynamic imports. This setup is causing `cannot find module './chunks/3381.js'` at runtime.
+
+Here's a working implementation 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
+ });
+};
+```
From 45666773757b6eaed6cc47ea0d77c521c9a335ec Mon Sep 17 00:00:00 2001
From: AndreyMay <51962295+AndreyMay@users.noreply.github.com>
Date: Sat, 14 Dec 2024 13:27:54 -0800
Subject: [PATCH 2/2] Update common_issues.mdx
---
pages/aws/common_issues.mdx | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/pages/aws/common_issues.mdx b/pages/aws/common_issues.mdx
index 490e72b..49c66e7 100644
--- a/pages/aws/common_issues.mdx
+++ b/pages/aws/common_issues.mdx
@@ -64,11 +64,15 @@ This can also happen in app router when a client navigates via NextJS `` c
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.
-#### Sentry does not work for api/server side + `cannot find module './chunks/3381.js'` error
+#### `cannot find module './chunks/xxxx.js'` error
-Sentry didn't work with the config recommended by Sentry docs which has `instrumentation.ts` with dynamic imports. This setup is causing `cannot find module './chunks/3381.js'` at runtime.
+Dynamic imports in `instrumentation.ts` will cause this error at runtime. Remove dynamic imports to resolve.
-Here's a working implementation which resolves the error:
+#### 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