Skip to content

Commit

Permalink
Remove un-necessary internal jest-worker error during ts/lint error (#…
Browse files Browse the repository at this point in the history
…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`
  • Loading branch information
ijjk committed Aug 24, 2022
1 parent 0e678db commit 1d9706f
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 39 deletions.
88 changes: 49 additions & 39 deletions packages/next/build/index.ts
Expand Up @@ -368,47 +368,57 @@ export default async function build(

const typeCheckStart = process.hrtime()

const [[verifyResult, typeCheckEnd]] = await Promise.all([
nextBuildSpan.traceChild('verify-typescript-setup').traceAsyncFn(() =>
verifyTypeScriptSetup(
dir,
[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(
try {
const [[verifyResult, typeCheckEnd]] = await Promise.all([
nextBuildSpan.traceChild('verify-typescript-setup').traceAsyncFn(() =>
verifyTypeScriptSetup(
dir,
eslintCacheDir,
config.eslint?.dirs,
[pagesDir, appDir].filter(Boolean) as string[],
!ignoreTypeScriptErrors,
config.typescript.tsconfigPath,
config.images.disableStaticImages,
cacheDir,
config.experimental.cpus,
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,
})
)
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,
eslintCacheDir,
config.eslint?.dirs,
config.experimental.cpus,
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 = {
Expand Down
2 changes: 2 additions & 0 deletions test/production/ci-missing-typescript-deps/index.test.ts
Expand Up @@ -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.`
)
expect(next.cliOutput).toContain(`Please install`)
expect(next.cliOutput).not.toContain('Call retries were exceeded')
expect(next.cliOutput).not.toContain('WorkerError')
} finally {
await next.destroy()
}
Expand Down

0 comments on commit 1d9706f

Please sign in to comment.