Unverified Commit d390c3d5 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Fix build traces case (#56817)

This ensures our `readFile` handling for tracing we previously had is
maintained.

Test deployment with the provided reproduction can be seen here:
https://react-pdf-repro-jeqgyhmek-vtest314-ijjk-testing.vercel.app/

Fixes: https://github.com/vercel/next.js/issues/56676
parent 46d56c6b
...@@ -24,6 +24,7 @@ import { defaultOverrides } from '../server/require-hook' ...@@ -24,6 +24,7 @@ import { defaultOverrides } from '../server/require-hook'
import { nodeFileTrace } from 'next/dist/compiled/@vercel/nft' import { nodeFileTrace } from 'next/dist/compiled/@vercel/nft'
import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path' import { normalizePagePath } from '../shared/lib/page-path/normalize-page-path'
import { normalizeAppPath } from '../shared/lib/router/utils/app-paths' import { normalizeAppPath } from '../shared/lib/router/utils/app-paths'
import isError from '../lib/is-error'
const debug = debugOriginal('next:build:build-traces') const debug = debugOriginal('next:build:build-traces')
...@@ -339,6 +340,45 @@ export async function collectBuildTraces({ ...@@ -339,6 +340,45 @@ export async function collectBuildTraces({
base: outputFileTracingRoot, base: outputFileTracingRoot,
processCwd: dir, processCwd: dir,
mixedModules: true, mixedModules: true,
async readFile(p) {
try {
return await fs.readFile(p, 'utf8')
} catch (e) {
if (isError(e) && (e.code === 'ENOENT' || e.code === 'EISDIR')) {
// handle temporary internal webpack files
if (p.match(/static[/\\]media/)) {
return ''
}
return null
}
throw e
}
},
async readlink(p) {
try {
return await fs.readlink(p)
} catch (e) {
if (
isError(e) &&
(e.code === 'EINVAL' ||
e.code === 'ENOENT' ||
e.code === 'UNKNOWN')
) {
return null
}
throw e
}
},
async stat(p) {
try {
return await fs.stat(p)
} catch (e) {
if (isError(e) && (e.code === 'ENOENT' || e.code === 'ENOTDIR')) {
return null
}
throw e
}
},
}) })
const reasons = result.reasons const reasons = result.reasons
const fileList = result.fileList const fileList = result.fileList
......
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