Unverified Commit 1d9706f4 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Remove un-necessary internal jest-worker error during ts/lint error (#39886)

This ensures we strip the un-necessary `jest-worker` error shown from an error with verifying TypeScript during build as this error just clutters the output and doesn't provide any additional helpful context. 

x-ref: [slack thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1661300070830909)

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
parent 0e678db5
...@@ -368,47 +368,57 @@ export default async function build( ...@@ -368,47 +368,57 @@ export default async function build(
const typeCheckStart = process.hrtime() const typeCheckStart = process.hrtime()
const [[verifyResult, typeCheckEnd]] = await Promise.all([ try {
nextBuildSpan.traceChild('verify-typescript-setup').traceAsyncFn(() => const [[verifyResult, typeCheckEnd]] = await Promise.all([
verifyTypeScriptSetup( nextBuildSpan.traceChild('verify-typescript-setup').traceAsyncFn(() =>
dir, verifyTypeScriptSetup(
[pagesDir, appDir].filter(Boolean) as string[],
!ignoreTypeScriptErrors,
config.typescript.tsconfigPath,
config.images.disableStaticImages,
cacheDir,
config.experimental.cpus,
config.experimental.workerThreads
).then((resolved) => {
const checkEnd = process.hrtime(typeCheckStart)
return [resolved, checkEnd] as const
})
),
shouldLint &&
nextBuildSpan.traceChild('verify-and-lint').traceAsyncFn(async () => {
await verifyAndLint(
dir, dir,
eslintCacheDir, [pagesDir, appDir].filter(Boolean) as string[],
config.eslint?.dirs, !ignoreTypeScriptErrors,
config.typescript.tsconfigPath,
config.images.disableStaticImages,
cacheDir,
config.experimental.cpus, config.experimental.cpus,
config.experimental.workerThreads, config.experimental.workerThreads
telemetry ).then((resolved) => {
) const checkEnd = process.hrtime(typeCheckStart)
}), return [resolved, checkEnd] as const
]) })
),
typeCheckingAndLintingSpinner?.stopAndPersist() shouldLint &&
nextBuildSpan
if (!ignoreTypeScriptErrors && verifyResult) { .traceChild('verify-and-lint')
telemetry.record( .traceAsyncFn(async () => {
eventTypeCheckCompleted({ await verifyAndLint(
durationInSeconds: typeCheckEnd[0], dir,
typescriptVersion: verifyResult.version, eslintCacheDir,
inputFilesCount: verifyResult.result?.inputFilesCount, config.eslint?.dirs,
totalFilesCount: verifyResult.result?.totalFilesCount, config.experimental.cpus,
incremental: verifyResult.result?.incremental, config.experimental.workerThreads,
}) telemetry
) )
}),
])
typeCheckingAndLintingSpinner?.stopAndPersist()
if (!ignoreTypeScriptErrors && verifyResult) {
telemetry.record(
eventTypeCheckCompleted({
durationInSeconds: typeCheckEnd[0],
typescriptVersion: verifyResult.version,
inputFilesCount: verifyResult.result?.inputFilesCount,
totalFilesCount: verifyResult.result?.totalFilesCount,
incremental: verifyResult.result?.incremental,
})
)
}
} catch (err) {
// prevent showing jest-worker internal error as it
// isn't helpful for users and clutters output
if (isError(err) && err.message === 'Call retries were exceeded') {
process.exit(1)
}
throw err
} }
const buildLintEvent: EventBuildFeatureUsage = { const buildLintEvent: EventBuildFeatureUsage = {
......
...@@ -26,6 +26,8 @@ describe('ci-missing-typescript-deps', () => { ...@@ -26,6 +26,8 @@ describe('ci-missing-typescript-deps', () => {
`It looks like you're trying to use TypeScript but do not have the required package(s) installed.` `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`
) )
expect(next.cliOutput).toContain(`Please install`) expect(next.cliOutput).toContain(`Please install`)
expect(next.cliOutput).not.toContain('Call retries were exceeded')
expect(next.cliOutput).not.toContain('WorkerError')
} finally { } finally {
await next.destroy() await next.destroy()
} }
......
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