Unverified Commit 53f21936 authored by Sebastian Markbåge's avatar Sebastian Markbåge Committed by GitHub

Don't filter out <anonymous> source location frames through RSC (#71752)

This lets us show Server Components (and Host Components) in the Parent
Stack passed to errors.

<img width="1039" alt="Screenshot 2024-10-23 at 12 51 10 PM"
src="https://github.com/user-attachments/assets/5912e750-b544-403d-8d5a-bce91c01b3a8">
parent ab32ccac
...@@ -4,6 +4,10 @@ const pathname = `${basePath}/__nextjs_source-map` ...@@ -4,6 +4,10 @@ const pathname = `${basePath}/__nextjs_source-map`
export const findSourceMapURL = export const findSourceMapURL =
process.env.NODE_ENV === 'development' process.env.NODE_ENV === 'development'
? function findSourceMapURL(filename: string): string | null { ? function findSourceMapURL(filename: string): string | null {
if (filename === '') {
return null
}
const url = new URL(pathname, document.location.origin) const url = new URL(pathname, document.location.origin)
url.searchParams.set( url.searchParams.set(
......
...@@ -1592,6 +1592,12 @@ async function renderToStream( ...@@ -1592,6 +1592,12 @@ async function renderToStream(
onError: serverComponentsErrorHandler, onError: serverComponentsErrorHandler,
environmentName: () => environmentName: () =>
requestStore.prerenderPhase === true ? 'Prerender' : 'Server', requestStore.prerenderPhase === true ? 'Prerender' : 'Server',
filterStackFrame(url: string, _functionName: string): boolean {
// The default implementation filters out <anonymous> 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')
},
} }
) )
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment