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,6 +368,7 @@ export default async function build( ...@@ -368,6 +368,7 @@ export default async function build(
const typeCheckStart = process.hrtime() const typeCheckStart = process.hrtime()
try {
const [[verifyResult, typeCheckEnd]] = await Promise.all([ const [[verifyResult, typeCheckEnd]] = await Promise.all([
nextBuildSpan.traceChild('verify-typescript-setup').traceAsyncFn(() => nextBuildSpan.traceChild('verify-typescript-setup').traceAsyncFn(() =>
verifyTypeScriptSetup( verifyTypeScriptSetup(
...@@ -385,7 +386,9 @@ export default async function build( ...@@ -385,7 +386,9 @@ export default async function build(
}) })
), ),
shouldLint && shouldLint &&
nextBuildSpan.traceChild('verify-and-lint').traceAsyncFn(async () => { nextBuildSpan
.traceChild('verify-and-lint')
.traceAsyncFn(async () => {
await verifyAndLint( await verifyAndLint(
dir, dir,
eslintCacheDir, eslintCacheDir,
...@@ -396,7 +399,6 @@ export default async function build( ...@@ -396,7 +399,6 @@ export default async function build(
) )
}), }),
]) ])
typeCheckingAndLintingSpinner?.stopAndPersist() typeCheckingAndLintingSpinner?.stopAndPersist()
if (!ignoreTypeScriptErrors && verifyResult) { if (!ignoreTypeScriptErrors && verifyResult) {
...@@ -410,6 +412,14 @@ export default async function build( ...@@ -410,6 +412,14 @@ export default async function build(
}) })
) )
} }
} 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 = {
featureName: 'build-lint', featureName: 'build-lint',
......
...@@ -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