From 30445948d2e33cd6d865f4f1ac570334228d08e3 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Tue, 22 Oct 2024 23:43:07 -0700 Subject: [PATCH] Don't filter out source location frames through RSC --- packages/next/src/client/app-find-source-map-url.ts | 4 ++++ packages/next/src/server/app-render/app-render.tsx | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/packages/next/src/client/app-find-source-map-url.ts b/packages/next/src/client/app-find-source-map-url.ts index b143c755568b7..d1946a5efa1ba 100644 --- a/packages/next/src/client/app-find-source-map-url.ts +++ b/packages/next/src/client/app-find-source-map-url.ts @@ -4,6 +4,10 @@ const pathname = `${basePath}/__nextjs_source-map` export const findSourceMapURL = process.env.NODE_ENV === 'development' ? function findSourceMapURL(filename: string): string | null { + if (filename === '') { + return null + } + const url = new URL(pathname, document.location.origin) url.searchParams.set( diff --git a/packages/next/src/server/app-render/app-render.tsx b/packages/next/src/server/app-render/app-render.tsx index 766c4d487da81..30c70b49ef01f 100644 --- a/packages/next/src/server/app-render/app-render.tsx +++ b/packages/next/src/server/app-render/app-render.tsx @@ -1592,6 +1592,12 @@ async function renderToStream( onError: serverComponentsErrorHandler, environmentName: () => requestStore.prerenderPhase === true ? 'Prerender' : 'Server', + filterStackFrame(url: string, _functionName: string): boolean { + // The default implementation filters out stack frames + // but we want to retain them because current Server Components and + // built-in Components in parent stacks don't have source location. + return !url.startsWith('node:') && !url.includes('node_modules') + }, } ) },