question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nextjs Build Failed with type: 'WorkerError'

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System: Platform: linux Arch: x64 Version: #43-Ubuntu SMP Wed Jun 15 12:54:21 UTC 2022 Binaries: Node: 16.15.0 npm: 8.5.5 Yarn: 1.22.18 pnpm: N/A Relevant packages: next: 12.2.1-canary.2 eslint-config-next: 12.1.6 react: 18.2.0 react-dom: 18.2.0

What browser are you using? (if relevant)

Using Brave (But it is irrelevent imo because error in building, dev works fine)

How are you deploying your application? (if relevant)

not deployed yet

Describe the Bug

Build fails with the following error messages on the console

yarn run v1.22.18
$ next build
info  - Loaded env from /home/rashid/code/projects/blog-web-next/.env
info  - Linting and checking validity of types  
info  - Creating an optimized production build  
info  - Compiled successfully
info  - Collecting page data ..node:internal/child_process/serialization:127
    const string = JSONStringify(message) + '\n';

{ the below error repeats 7-8 times }

TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'ClientRequest'
    |     property 'socket' -> object with constructor 'TLSSocket'
    --- property '_httpMessage' closes the circle
    at stringify (<anonymous>)
    at writeChannelMessage (node:internal/child_process/serialization:127:20)
    at process.target._send (node:internal/child_process:839:17)
    at process.target.send (node:internal/child_process:739:19)
    at reportError (/home/rashid/code/projects/blog-web-next/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1995)
    at reportClientError (/home/rashid/code/projects/blog-web-next/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1671)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
info  - Collecting page data .node:internal/child_process/serialization:127
    const string = JSONStringify(message) + '\n';

{ and then finally this error }

> Build error occurred
Error: Call retries were exceeded
    at ChildProcessWorker.initialize (/home/rashid/code/projects/blog-web-next/node_modules/next/dist/compiled/jest-worker/index.js:1:11661)
    at ChildProcessWorker._onExit (/home/rashid/code/projects/blog-web-next/node_modules/next/dist/compiled/jest-worker/index.js:1:12599)
    at ChildProcess.emit (node:events:527:28)
    at ChildProcess.emit (node:domain:475:12)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12) {
  type: 'WorkerError'

Expected Behavior

Build create Successfully

Link to reproduction

https://github.com/m3rashid/blog-web-next

To Reproduce

run the following command

yarn build

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ryanmrcommented, Jul 22, 2022

Hi all,

I recently encountered this with a project on yarn build with next latest (which at this 12.2.2), just as balazsorban44 mentioned. It was occurring in my ci runner, and I realized someone else on the team was using getStaticPaths referencing an api route that wasn’t available in ci. For some reason though, getStaticPaths wanted to serialize the error that was produced (which was stemming from axios not being to reach the api), and the serialization failed.

1reaction
balazsorban44commented, Jul 11, 2022

I traced it back to some axios-related issues.

Given this code in pages/[slug].js

import axios from "axios"

export default function Page() {}

export async function getStaticProps() {
  return { props: {} }
}

export async function getStaticPaths() {
  try {
    await axios.post("https://cubicle.vercel.app/api/post/card")
  } catch (error) {
    console.log(error)
  } finally {
    return { paths: [], fallback: true }
  }
}

The error appears.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Nextjs build failed with 'workerError' - typescript - Stack Overflow
onexit (node:internal/child_process:291:12) { type: 'WorkerError' } error Command failed with exit code 1. info Visit https://yarnpkg.com/en/ ...
Read more >
Error in nextjs production build (Just in production)
Well we have been doing builds and deploys for 3 months but ... _handle.onexit (node:internal/child_process:290:12) { type: 'WorkerError' }.
Read more >
Ignoring TypeScript Errors - next.config.js
js fails your production build ( next build ) when TypeScript errors are present in your project. If you'd like Next.js to dangerously...
Read more >
Something went wrong when we tried to build your project
_handle.onexit (internal/child_process.js:277:12) { type: 'WorkerError' } error Call retries were exceeded. FAILURE: Build failed with an ...
Read more >
next build시 에러가 발생합니다. - 인프런 | 질문 & 답변
next build로 빌드를 하는 과정에서 다음과 같은 에러가 발생 ... _handle.onexit (node:internal/child_process:290:12) { type: 'WorkerError' }
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found