Unverified Commit d40ecb7f authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Resolve RSC / HTML rendering errors in error overlay (#43332)

parent 1dd34620
...@@ -39,6 +39,7 @@ export function getOriginalStackFrame( ...@@ -39,6 +39,7 @@ export function getOriginalStackFrame(
const params = new URLSearchParams() const params = new URLSearchParams()
params.append('isServer', String(type === 'server')) params.append('isServer', String(type === 'server'))
params.append('isEdgeServer', String(type === 'edge-server')) params.append('isEdgeServer', String(type === 'edge-server'))
params.append('isAppDirectory', 'true')
params.append('errorMessage', errorMessage) params.append('errorMessage', errorMessage)
for (const key in source) { for (const key in source) {
params.append(key, ((source as any)[key] ?? '').toString()) params.append(key, ((source as any)[key] ?? '').toString())
......
...@@ -1053,7 +1053,8 @@ export default class DevServer extends Server { ...@@ -1053,7 +1053,8 @@ export default class DevServer extends Server {
({ file }) => ({ file }) =>
!file?.startsWith('eval') && !file?.startsWith('eval') &&
!file?.includes('web/adapter') && !file?.includes('web/adapter') &&
!file?.includes('sandbox/context') !file?.includes('sandbox/context') &&
!file?.includes('<anonymous>')
)! )!
if (frame.lineNumber && frame?.file) { if (frame.lineNumber && frame?.file) {
...@@ -1061,10 +1062,15 @@ export default class DevServer extends Server { ...@@ -1061,10 +1062,15 @@ export default class DevServer extends Server {
/^(webpack-internal:\/\/\/|file:\/\/)/, /^(webpack-internal:\/\/\/|file:\/\/)/,
'' ''
) )
const modulePath = frame.file.replace(
/^(webpack-internal:\/\/\/|file:\/\/)(\(.*\)\/)?/,
''
)
const src = getErrorSource(err as Error) const src = getErrorSource(err as Error)
const isEdgeCompiler = src === COMPILER_NAMES.edgeServer
const compilation = ( const compilation = (
src === COMPILER_NAMES.edgeServer isEdgeCompiler
? this.hotReloader?.edgeServerStats?.compilation ? this.hotReloader?.edgeServerStats?.compilation
: this.hotReloader?.serverStats?.compilation : this.hotReloader?.serverStats?.compilation
)! )!
...@@ -1080,10 +1086,16 @@ export default class DevServer extends Server { ...@@ -1080,10 +1086,16 @@ export default class DevServer extends Server {
column: frame.column, column: frame.column,
source, source,
frame, frame,
modulePath: moduleId, moduleId,
modulePath,
rootDirectory: this.dir, rootDirectory: this.dir,
errorMessage: err.message, errorMessage: err.message,
compilation, serverCompilation: isEdgeCompiler
? undefined
: this.hotReloader?.serverStats?.compilation,
edgeCompilation: isEdgeCompiler
? this.hotReloader?.edgeServerStats?.compilation
: undefined,
}) })
if (originalFrame) { if (originalFrame) {
...@@ -1093,7 +1105,7 @@ export default class DevServer extends Server { ...@@ -1093,7 +1105,7 @@ export default class DevServer extends Server {
Log[type === 'warning' ? 'warn' : 'error']( Log[type === 'warning' ? 'warn' : 'error'](
`${file} (${lineNumber}:${column}) @ ${methodName}` `${file} (${lineNumber}:${column}) @ ${methodName}`
) )
if (src === COMPILER_NAMES.edgeServer) { if (isEdgeCompiler) {
err = err.message err = err.message
} }
if (type === 'warning') { if (type === 'warning') {
......
...@@ -389,7 +389,7 @@ export async function ncc_next__react_dev_overlay(task, opts) { ...@@ -389,7 +389,7 @@ export async function ncc_next__react_dev_overlay(task, opts) {
precompiled: false, precompiled: false,
packageName: '@next/react-dev-overlay', packageName: '@next/react-dev-overlay',
externals: overlayExternals, externals: overlayExternals,
target: 'es5', target: 'es2018',
}) })
.target('dist/compiled/@next/react-dev-overlay/dist') .target('dist/compiled/@next/react-dev-overlay/dist')
......
...@@ -41,9 +41,10 @@ function getModuleById( ...@@ -41,9 +41,10 @@ function getModuleById(
id: string | undefined, id: string | undefined,
compilation: webpack.Compilation compilation: webpack.Compilation
) { ) {
return [...compilation.modules].find( return [...compilation.modules].find((searchModule) => {
(searchModule) => getModuleId(compilation, searchModule) === id const moduleId = getModuleId(compilation, searchModule)
) return moduleId === id
})
} }
function findModuleNotFoundFromError(errorMessage: string | undefined) { function findModuleNotFoundFromError(errorMessage: string | undefined) {
...@@ -112,11 +113,11 @@ async function findOriginalSourcePositionAndContent( ...@@ -112,11 +113,11 @@ async function findOriginalSourcePositionAndContent(
} }
function findOriginalSourcePositionAndContentFromCompilation( function findOriginalSourcePositionAndContentFromCompilation(
modulePath: string | undefined, moduleId: string | undefined,
importedModule: string, importedModule: string,
compilation: webpack.Compilation compilation: webpack.Compilation
) { ) {
const module = getModuleById(modulePath, compilation) const module = getModuleById(moduleId, compilation)
return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null return module?.buildInfo?.importLocByPath?.get(importedModule) ?? null
} }
...@@ -124,33 +125,66 @@ export async function createOriginalStackFrame({ ...@@ -124,33 +125,66 @@ export async function createOriginalStackFrame({
line, line,
column, column,
source, source,
moduleId,
modulePath, modulePath,
rootDirectory, rootDirectory,
frame, frame,
errorMessage, errorMessage,
compilation, clientCompilation,
serverCompilation,
edgeCompilation,
}: { }: {
line: number line: number
column: number | null column: number | null
source: any source: any
moduleId?: string
modulePath?: string modulePath?: string
rootDirectory: string rootDirectory: string
frame: any frame: any
errorMessage?: string errorMessage?: string
compilation?: webpack.Compilation clientCompilation?: webpack.Compilation
serverCompilation?: webpack.Compilation
edgeCompilation?: webpack.Compilation
}): Promise<OriginalStackFrameResponse | null> { }): Promise<OriginalStackFrameResponse | null> {
const moduleNotFound = findModuleNotFoundFromError(errorMessage) const moduleNotFound = findModuleNotFoundFromError(errorMessage)
const result = const result = await (async () => {
moduleNotFound && compilation if (moduleNotFound) {
? findOriginalSourcePositionAndContentFromCompilation( let moduleNotFoundResult = null
modulePath,
if (clientCompilation) {
moduleNotFoundResult =
findOriginalSourcePositionAndContentFromCompilation(
moduleId,
moduleNotFound, moduleNotFound,
compilation clientCompilation
) )
: await findOriginalSourcePositionAndContent(source, { }
if (moduleNotFoundResult === null && serverCompilation) {
moduleNotFoundResult =
findOriginalSourcePositionAndContentFromCompilation(
moduleId,
moduleNotFound,
serverCompilation
)
}
if (moduleNotFoundResult === null && edgeCompilation) {
moduleNotFoundResult =
findOriginalSourcePositionAndContentFromCompilation(
moduleId,
moduleNotFound,
edgeCompilation
)
}
return moduleNotFoundResult
}
return await findOriginalSourcePositionAndContent(source, {
line, line,
column, column,
}) })
})()
if (result === null) { if (result === null) {
return null return null
...@@ -164,7 +198,12 @@ export async function createOriginalStackFrame({ ...@@ -164,7 +198,12 @@ export async function createOriginalStackFrame({
const filePath = path.resolve( const filePath = path.resolve(
rootDirectory, rootDirectory,
modulePath || getSourcePath(sourcePosition.source) getSourcePath(
// When sourcePosition.source is the loader path the modulePath is generally better.
(sourcePosition.source.includes('|')
? modulePath
: sourcePosition.source) || modulePath
)
) )
const originalFrame: StackFrame = { const originalFrame: StackFrame = {
...@@ -173,7 +212,11 @@ export async function createOriginalStackFrame({ ...@@ -173,7 +212,11 @@ export async function createOriginalStackFrame({
: sourcePosition.source, : sourcePosition.source,
lineNumber: sourcePosition.line, lineNumber: sourcePosition.line,
column: sourcePosition.column, column: sourcePosition.column,
methodName: frame.methodName, // TODO: resolve original method name (?) methodName:
sourcePosition.name ||
// default is not a valid identifier in JS so webpack uses a custom variable when it's an unnamed default export
// Resolve it back to `default` for the method name if the source position didn't have the method.
frame.methodName?.replace('__WEBPACK_DEFAULT_EXPORT__', 'default'),
arguments: [], arguments: [],
} }
...@@ -250,8 +293,14 @@ function getOverlayMiddleware(options: OverlayMiddlewareOptions) { ...@@ -250,8 +293,14 @@ function getOverlayMiddleware(options: OverlayMiddlewareOptions) {
const frame = query as unknown as StackFrame & { const frame = query as unknown as StackFrame & {
isEdgeServer: 'true' | 'false' isEdgeServer: 'true' | 'false'
isServer: 'true' | 'false' isServer: 'true' | 'false'
isAppDirectory: 'true' | 'false'
errorMessage: string | undefined errorMessage: string | undefined
} }
const isAppDirectory = frame.isAppDirectory === 'true'
const isServerError = frame.isServer === 'true'
const isEdgeServerError = frame.isEdgeServer === 'true'
const isClientError = !isServerError && !isEdgeServerError
if ( if (
!( !(
(frame.file?.startsWith('webpack-internal:///') || (frame.file?.startsWith('webpack-internal:///') ||
...@@ -268,20 +317,45 @@ function getOverlayMiddleware(options: OverlayMiddlewareOptions) { ...@@ -268,20 +317,45 @@ function getOverlayMiddleware(options: OverlayMiddlewareOptions) {
/^(webpack-internal:\/\/\/|file:\/\/)/, /^(webpack-internal:\/\/\/|file:\/\/)/,
'' ''
) )
const modulePath = frame.file.replace(
/^(webpack-internal:\/\/\/|file:\/\/)(\(.*\)\/)?/,
''
)
let source: Source let source: Source = null
const compilation = const clientCompilation = options.stats()?.compilation
frame.isEdgeServer === 'true' const serverCompilation = options.serverStats()?.compilation
? options.edgeServerStats()?.compilation const edgeCompilation = options.edgeServerStats()?.compilation
: frame.isServer === 'true'
? options.serverStats()?.compilation
: options.stats()?.compilation
try { try {
if (isClientError || isAppDirectory) {
// Try Client Compilation first
// In `pages` we leverage `isClientError` to check
// In `app` it depends on if it's a server / client component and when the code throws. E.g. during HTML rendering it's the server/edge compilation.
source = await getSourceById(
frame.file.startsWith('file:'),
moduleId,
clientCompilation
)
}
// Try Server Compilation
// In `pages` this could be something imported in getServerSideProps/getStaticProps as the code for those is tree-shaken.
// In `app` this finds server components and code that was imported from a server component. It also covers when client component code throws during HTML rendering.
if ((isServerError || isAppDirectory) && source === null) {
source = await getSourceById( source = await getSourceById(
frame.file.startsWith('file:'), frame.file.startsWith('file:'),
moduleId, moduleId,
compilation serverCompilation
) )
}
// Try Edge Server Compilation
// Both cases are the same as Server Compilation, main difference is that it covers `runtime: 'edge'` pages/app routes.
if ((isEdgeServerError || isAppDirectory) && source === null) {
source = await getSourceById(
frame.file.startsWith('file:'),
moduleId,
edgeCompilation
)
}
} catch (err) { } catch (err) {
console.log('Failed to get source map:', err) console.log('Failed to get source map:', err)
res.statusCode = 500 res.statusCode = 500
...@@ -310,10 +384,13 @@ function getOverlayMiddleware(options: OverlayMiddlewareOptions) { ...@@ -310,10 +384,13 @@ function getOverlayMiddleware(options: OverlayMiddlewareOptions) {
column: frameColumn, column: frameColumn,
source, source,
frame, frame,
modulePath: moduleId, moduleId,
modulePath,
rootDirectory: options.rootDirectory, rootDirectory: options.rootDirectory,
errorMessage: frame.errorMessage, errorMessage: frame.errorMessage,
compilation, clientCompilation: isClientError ? clientCompilation : undefined,
serverCompilation: isServerError ? serverCompilation : undefined,
edgeCompilation: isEdgeServerError ? edgeCompilation : undefined,
}) })
if (originalStackFrameResponse === null) { if (originalStackFrameResponse === null) {
......
...@@ -4,14 +4,15 @@ ...@@ -4,14 +4,15 @@
"sourceMap": true, "sourceMap": true,
"strict": true, "strict": true,
"esModuleInterop": true, "esModuleInterop": true,
"target": "es3", "target": "es2020",
"lib": ["dom"], "lib": ["dom"],
"downlevelIteration": true, "downlevelIteration": true,
"preserveWatchOutput": true, "preserveWatchOutput": true,
"outDir": "dist", "outDir": "dist",
"jsx": "react", "jsx": "react",
"noFallthroughCasesInSwitch": true, "noFallthroughCasesInSwitch": true,
"skipLibCheck": true "skipLibCheck": true,
"moduleResolution": "Node16"
}, },
"include": ["src/**/*.ts", "src/**/*.tsx"], "include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules"] "exclude": ["node_modules"]
......
...@@ -270,25 +270,65 @@ describe('ReactRefreshRegression app', () => { ...@@ -270,25 +270,65 @@ describe('ReactRefreshRegression app', () => {
// https://github.com/vercel/next.js/issues/11504 // https://github.com/vercel/next.js/issues/11504
// TODO-APP: fix case where error is not resolved to source correctly. // TODO-APP: fix case where error is not resolved to source correctly.
test.skip('shows an overlay for a server-side error', async () => { test('shows an overlay for anonymous function server-side error', async () => {
const { session, cleanup } = await sandbox(next) const { session, browser, cleanup } = await sandbox(next)
await session.patch( await session.patch(
'app/page.js', 'app/page.js',
`export default function () { throw new Error('pre boom'); }` `export default function () { throw new Error('boom'); }`
) )
const didNotReload = await session.patch( await browser.refresh()
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source.split(/\r?\n/g).slice(2).join('\n')).toMatchInlineSnapshot(`
"> 1 | export default function () { throw new Error('boom'); }
| ^"
`)
await cleanup()
})
test('shows an overlay for server-side error in server component', async () => {
const { session, browser, cleanup } = await sandbox(next)
await session.patch(
'app/page.js', 'app/page.js',
`export default function () { throw new Error('boom'); }` `export default function Page() { throw new Error('boom'); }`
)
await browser.refresh()
expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource()
expect(source.split(/\r?\n/g).slice(2).join('\n')).toMatchInlineSnapshot(`
"> 1 | export default function Page() { throw new Error('boom'); }
| ^"
`)
await cleanup()
})
test('shows an overlay for server-side error in client component', async () => {
const { session, browser, cleanup } = await sandbox(next)
await session.patch(
'app/page.js',
`'use client'
export default function Page() { throw new Error('boom'); }`
) )
expect(didNotReload).toBe(false)
await browser.refresh()
expect(await session.hasRedbox(true)).toBe(true) expect(await session.hasRedbox(true)).toBe(true)
const source = await session.getRedboxSource() const source = await session.getRedboxSource()
expect(source.split(/\r?\n/g).slice(2).join('\n')).toMatchInlineSnapshot(` expect(source.split(/\r?\n/g).slice(2).join('\n')).toMatchInlineSnapshot(`
"> 1 | export default function () { throw new Error('boom'); } " 1 | 'use client'
> 2 | export default function Page() { throw new Error('boom'); }
| ^" | ^"
`) `)
......
...@@ -115,7 +115,7 @@ exports[`ReactRefreshLogBox app stuck error 1`] = ` ...@@ -115,7 +115,7 @@ exports[`ReactRefreshLogBox app stuck error 1`] = `
`; `;
exports[`ReactRefreshLogBox app syntax > runtime error 1`] = ` exports[`ReactRefreshLogBox app syntax > runtime error 1`] = `
"index.js (6:16) @ eval "index.js (6:16) @ Error
4 | setInterval(() => { 4 | setInterval(() => {
5 | i++ 5 | i++
......
...@@ -22,6 +22,7 @@ export async function sandbox( ...@@ -22,6 +22,7 @@ export async function sandbox(
await next.start() await next.start()
const browser = await webdriver(next.appPort, '/') const browser = await webdriver(next.appPort, '/')
return { return {
browser,
session: { session: {
async write(filename, content) { async write(filename, content) {
// Update the file on filesystem // Update the file on filesystem
......
...@@ -358,11 +358,7 @@ describe('ReactRefreshLogBox', () => { ...@@ -358,11 +358,7 @@ describe('ReactRefreshLogBox', () => {
) )
expect(await session.hasRedbox(true)).toBe(true) expect(await session.hasRedbox(true)).toBe(true)
if (process.platform === 'win32') {
expect(await session.getRedboxSource()).toMatchSnapshot()
} else {
expect(await session.getRedboxSource()).toMatchSnapshot() expect(await session.getRedboxSource()).toMatchSnapshot()
}
await cleanup() await cleanup()
}) })
......
...@@ -127,7 +127,7 @@ exports[`ReactRefreshLogBox stuck error 1`] = ` ...@@ -127,7 +127,7 @@ exports[`ReactRefreshLogBox stuck error 1`] = `
`; `;
exports[`ReactRefreshLogBox syntax > runtime error 1`] = ` exports[`ReactRefreshLogBox syntax > runtime error 1`] = `
"index.js (6:16) @ eval "index.js (6:16) @ Error
4 | setInterval(() => { 4 | setInterval(() => {
5 | i++ 5 | i++
......
...@@ -24,7 +24,7 @@ describe('api-route-errors cli output', () => { ...@@ -24,7 +24,7 @@ describe('api-route-errors cli output', () => {
const output = stripAnsi(next.cliOutput.slice(outputIndex)) const output = stripAnsi(next.cliOutput.slice(outputIndex))
// Location // Location
expect(output).toContain('error - (api)/pages/api/error.js (2:8) @ error') expect(output).toContain('error - pages/api/error.js (2:8) @ error')
// Stack // Stack
expect(output).toContain('pages/api/error.js:6:11') expect(output).toContain('pages/api/error.js:6:11')
// Source code // Source code
...@@ -39,7 +39,7 @@ describe('api-route-errors cli output', () => { ...@@ -39,7 +39,7 @@ describe('api-route-errors cli output', () => {
const output = stripAnsi(next.cliOutput.slice(outputIndex)) const output = stripAnsi(next.cliOutput.slice(outputIndex))
// Location // Location
expect(output).toContain( expect(output).toContain(
'error - (api)/pages/api/uncaught-exception.js (3:10) @ Timeout' 'error - pages/api/uncaught-exception.js (3:10) @ Timeout'
) )
// Stack // Stack
expect(output).toContain('pages/api/uncaught-exception.js:7:15') expect(output).toContain('pages/api/uncaught-exception.js:7:15')
...@@ -57,7 +57,7 @@ describe('api-route-errors cli output', () => { ...@@ -57,7 +57,7 @@ describe('api-route-errors cli output', () => {
const output = stripAnsi(next.cliOutput.slice(outputIndex)) const output = stripAnsi(next.cliOutput.slice(outputIndex))
// Location // Location
expect(output).toContain( expect(output).toContain(
'error - (api)/pages/api/unhandled-rejection.js (2:17) @ unhandledRejection' 'error - pages/api/unhandled-rejection.js (2:17) @ unhandledRejection'
) )
// Stack // Stack
expect(output).toContain('pages/api/unhandled-rejection.js:6:20') expect(output).toContain('pages/api/unhandled-rejection.js:6:20')
......
...@@ -536,12 +536,7 @@ describe('basic HMR', () => { ...@@ -536,12 +536,7 @@ describe('basic HMR', () => {
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
// TODO: Replace this when webpack 5 is the default // TODO: Replace this when webpack 5 is the default
expect( expect(await getRedboxHeader(browser)).toMatch(
(await getRedboxHeader(browser)).replace(
'__WEBPACK_DEFAULT_EXPORT__',
'Unknown'
)
).toMatch(
`Objects are not valid as a React child (found: ${ `Objects are not valid as a React child (found: ${
isReact17 ? '/search/' : '[object RegExp]' isReact17 ? '/search/' : '[object RegExp]'
}). If you meant to render a collection of children, use an array instead.` }). If you meant to render a collection of children, use an array instead.`
......
...@@ -601,12 +601,7 @@ describe('basic HMR', () => { ...@@ -601,12 +601,7 @@ describe('basic HMR', () => {
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
// TODO: Replace this when webpack 5 is the default // TODO: Replace this when webpack 5 is the default
expect( expect(await getRedboxHeader(browser)).toMatch(
(await getRedboxHeader(browser)).replace(
'__WEBPACK_DEFAULT_EXPORT__',
'Unknown'
)
).toMatch(
`Objects are not valid as a React child (found: ${ `Objects are not valid as a React child (found: ${
isReact17 ? '/search/' : '[object RegExp]' isReact17 ? '/search/' : '[object RegExp]'
}). If you meant to render a collection of children, use an array instead.` }). If you meant to render a collection of children, use an array instead.`
......
...@@ -58,7 +58,7 @@ describe('Middleware development errors', () => { ...@@ -58,7 +58,7 @@ describe('Middleware development errors', () => {
const output = stripAnsi(context.logs.output) const output = stripAnsi(context.logs.output)
expect(output).toMatch( expect(output).toMatch(
new RegExp( new RegExp(
`error - \\(middleware\\)/middleware.js \\(\\d+:\\d+\\) @ Object.__WEBPACK_DEFAULT_EXPORT__ \\[as handler\\]\nerror - boom`, `error - middleware.js \\(\\d+:\\d+\\) @ Object.default \\[as handler\\]\nerror - boom`,
'm' 'm'
) )
) )
...@@ -93,7 +93,7 @@ describe('Middleware development errors', () => { ...@@ -93,7 +93,7 @@ describe('Middleware development errors', () => {
const output = stripAnsi(context.logs.output) const output = stripAnsi(context.logs.output)
expect(output).toMatch( expect(output).toMatch(
new RegExp( new RegExp(
`error - \\(middleware\\)/middleware.js \\(\\d+:\\d+\\) @ throwError\nerror - unhandledRejection: async boom!`, `error - middleware.js \\(\\d+:\\d+\\) @ throwError\nerror - unhandledRejection: async boom!`,
'm' 'm'
) )
) )
...@@ -124,7 +124,7 @@ describe('Middleware development errors', () => { ...@@ -124,7 +124,7 @@ describe('Middleware development errors', () => {
const output = stripAnsi(context.logs.output) const output = stripAnsi(context.logs.output)
expect(output).toMatch( expect(output).toMatch(
new RegExp( new RegExp(
`error - \\(middleware\\)/middleware.js \\(\\d+:\\d+\\) @ eval\nerror - test is not defined`, `error - middleware.js \\(\\d+:\\d+\\) @ eval\nerror - test is not defined`,
'm' 'm'
) )
) )
...@@ -157,7 +157,7 @@ describe('Middleware development errors', () => { ...@@ -157,7 +157,7 @@ describe('Middleware development errors', () => {
const output = stripAnsi(context.logs.output) const output = stripAnsi(context.logs.output)
expect(output).toMatch( expect(output).toMatch(
new RegExp( new RegExp(
`error - \\(middleware\\)/middleware.js \\(\\d+:\\d+\\) @ <unknown>\nerror - booooom!`, `error - middleware.js \\(\\d+:\\d+\\) @ <unknown>\nerror - booooom!`,
'm' 'm'
) )
) )
...@@ -195,7 +195,7 @@ describe('Middleware development errors', () => { ...@@ -195,7 +195,7 @@ describe('Middleware development errors', () => {
const output = stripAnsi(context.logs.output) const output = stripAnsi(context.logs.output)
expect(output).toMatch( expect(output).toMatch(
new RegExp( new RegExp(
`error - \\(middleware\\)/middleware.js \\(\\d+:\\d+\\) @ eval\nerror - unhandledRejection: you shall see me`, `error - middleware.js \\(\\d+:\\d+\\) @ eval\nerror - unhandledRejection: you shall see me`,
'm' 'm'
) )
) )
...@@ -227,7 +227,7 @@ describe('Middleware development errors', () => { ...@@ -227,7 +227,7 @@ describe('Middleware development errors', () => {
const output = stripAnsi(context.logs.output) const output = stripAnsi(context.logs.output)
expect(output).toMatch( expect(output).toMatch(
new RegExp( new RegExp(
`error - \\(middleware\\)/lib/unhandled.js \\(\\d+:\\d+\\) @ Timeout.eval \\[as _onTimeout\\]\nerror - uncaughtException: This file asynchronously fails while loading`, `error - lib/unhandled.js \\(\\d+:\\d+\\) @ Timeout.eval \\[as _onTimeout\\]\nerror - uncaughtException: This file asynchronously fails while loading`,
'm' 'm'
) )
) )
......
...@@ -649,13 +649,13 @@ export async function getRedboxHeader(browser) { ...@@ -649,13 +649,13 @@ export async function getRedboxHeader(browser) {
evaluate(browser, () => { evaluate(browser, () => {
const portal = [].slice const portal = [].slice
.call(document.querySelectorAll('nextjs-portal')) .call(document.querySelectorAll('nextjs-portal'))
.find((p) => p.shadowRoot.querySelector('[data-nextjs-dialog-header')) .find((p) =>
p.shadowRoot.querySelector('[data-nextjs-dialog-header]')
)
const root = portal.shadowRoot const root = portal.shadowRoot
return root return root.querySelector('[data-nextjs-dialog-header]').innerText
.querySelector('[data-nextjs-dialog-header]')
.innerText.replace(/__WEBPACK_DEFAULT_EXPORT__/, 'Unknown')
}), }),
3000, 10000,
500, 500,
'getRedboxHeader' 'getRedboxHeader'
) )
...@@ -673,11 +673,11 @@ export async function getRedboxSource(browser) { ...@@ -673,11 +673,11 @@ export async function getRedboxSource(browser) {
) )
) )
const root = portal.shadowRoot const root = portal.shadowRoot
return root return root.querySelector(
.querySelector('[data-nextjs-codeframe], [data-nextjs-terminal]') '[data-nextjs-codeframe], [data-nextjs-terminal]'
.innerText.replace(/__WEBPACK_DEFAULT_EXPORT__/, 'Unknown') ).innerText
}), }),
3000, 10000,
500, 500,
'getRedboxSource' 'getRedboxSource'
) )
...@@ -693,9 +693,7 @@ export async function getRedboxDescription(browser) { ...@@ -693,9 +693,7 @@ export async function getRedboxDescription(browser) {
p.shadowRoot.querySelector('[data-nextjs-dialog-header]') p.shadowRoot.querySelector('[data-nextjs-dialog-header]')
) )
const root = portal.shadowRoot const root = portal.shadowRoot
return root return root.querySelector('#nextjs__container_errors_desc').innerText
.querySelector('#nextjs__container_errors_desc')
.innerText.replace(/__WEBPACK_DEFAULT_EXPORT__/, 'Unknown')
}), }),
3000, 3000,
500, 500,
......
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