Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next 10.1 respawns infinite jest-worker child processes #23519

Closed
markerikson opened this issue Mar 29, 2021 · 17 comments
Closed

Next 10.1 respawns infinite jest-worker child processes #23519

markerikson opened this issue Mar 29, 2021 · 17 comments
Assignees
Labels
Webpack Related to Webpack with Next.js.

Comments

@markerikson
Copy link

markerikson commented Mar 29, 2021

What version of Next.js are you using?

10.1.0

What version of Node.js are you using?

12.18.3

What browser are you using?

N/A

What operating system are you using?

Windows 10.1809

How are you deploying your application?

next dev

Describe the Bug

I have a Next application that's been running on 10.0.3. I just tried to update it to 10.1.0, and now every time I start next dev, my CPU pegs to 100% and stays there. Inspecting the process tree, I see the parent Next process, a couple children, and then an infinite series of child jest-worker processes that are spawning, dying, and re-spawning. The jest-worker process respawns appear to be the culprit for the CPU usage:

image

Part of the excess CPU usage is due to this corporate machine having extra process security checks that slow down Windows process creation. However, previous versions of Next worked just fine, and I can confirm that the behavior first appears in 10.0.10-canary.1 .

Expected Behavior

Next would start, eat some CPU and spawn a few processes during startup, but then settle down to idle after initial setup is complete.

To Reproduce

Haven't tried reproducing this as a standalone project or repro. But, I've stepped my way through a dozen different Next versions within our repo, and I can confirm that this first appeared in version 10.0.10-canary.1.

Some of the 10.x versions I tried, and their results:

  • 0.6, 0.7: work (no extra processes)
  • 0.8, 0.9, 0.10-c.0: crash on startup (EPIPE)
  • 0.10-c.1 and up: failure (extra processes)

Each time, all I've done is:

yarn add next@10.0.$SOME_VERSION
yarn dev

If I compare v10.0.10-canary.0...v10.0.10-canary.1 , I see that canary.1 includes #23077 , which is an update to the jest-worker library.

That PR seems like the likely candidate to have modified the child process behavior.

@markerikson markerikson added the bug Issue was opened via the bug report template. label Mar 29, 2021
@Timer Timer added this to the Iteration 18 milestone Mar 30, 2021
@Timer Timer added kind: bug and removed bug Issue was opened via the bug report template. labels Mar 30, 2021
@rkrv
Copy link

rkrv commented Apr 1, 2021

I'm getting the same error; works for my co-workers don't work for me; the same setup; pinned to 10.0.7 for now.

@CharlieHess
Copy link

CharlieHess commented Apr 1, 2021

Same problem here after upgrading from 10.0.x → 10.2.x; I see a forever-hang after running yarn dev. Sometimes it doesn't hang but crashes immediately with an EPIPE error in jest-worker:

[...]/node_modules/jest-worker/build/workers/ChildProcessWorker.js:181
    child.send([
          ^
TypeError: child.send is not a function
    at ChildProcessWorker.initialize ([...]/node_modules/jest-worker/build/workers/ChildProcessWorker.js:181:11)
    at ChildProcessWorker._onExit ([...]/node_modules/jest-worker/build/workers/ChildProcessWorker.js:275:12)

I'm on macOS Big Sur so it looks like this problem is cross-platform.

@markerikson
Copy link
Author

I'm kinda relieved to see other folks reporting this as well. nice to know it wasn't just me or my machine :)

@egeriis
Copy link

egeriis commented Apr 2, 2021

This is a transient issue for me at least. Resolves by running yarn dev again. I understand that's not a solution, but it can be helpful to avoid downgrading.

@egeriis
Copy link

egeriis commented Apr 2, 2021

I've yet to find the culprit, but my initial findings indicate that this pertains to Node.js 12, and doesn't happen with v14.

@markerikson
Copy link
Author

@egeriis Good to know. It was very consistent for me when I switched to a version that had the worker upgrade, but yes, I'm running Node 12.18 atm.

I can push through an upgrade to Node 14 for both our dev and deployment environments, but it'd also be nice to know why this is happening :)

@egeriis
Copy link

egeriis commented Apr 2, 2021

@markerikson Yeah, unfortunately it wasn't apparent where the error happened, so I had to switch away from debugging the issue.

@rkrv
Copy link

rkrv commented Apr 6, 2021

Upgrading node to v14 solved the problem for me

@quinn
Copy link

quinn commented May 29, 2021

this is happening for me on next.js 10.2.3 and node version 16.2.0. I have to kill -9 the parent node process every time (killing it removes all of the jest-workers, around 10 i think)

@markerikson
Copy link
Author

FWIW, I ended up upgrading our app to run on Node 14, and went from Next 10.0 to 10.2 on the day it came out. Runs fine, no problems here.

So, the workaround is definitely upgrading to Node 14.

@quinn
Copy link

quinn commented May 29, 2021

thanks @markerikson, i downgraded to 14.17.0, same problem. 😔

@quinn
Copy link

quinn commented May 29, 2021

i tried to use debugger, but it got confusing with all of the jest-workers. not sure where things are breaking down

@quinn
Copy link

quinn commented May 29, 2021

My issue may be unrelated. I tried running with debugger and setting it to break on "uncaught exceptions", and it seems an import was failing. I don't know why this caused the jest-workers to go into an infinite loop. Other broken imports seem ok, but for whatever reason this one in particular doesn't work (its for windi.css)

@styfle styfle added this to the 12.0.4 milestone Nov 5, 2021
@timneutkens timneutkens added the Webpack Related to Webpack with Next.js. label Nov 16, 2021
@timneutkens timneutkens removed this from the 12.0.5 milestone Nov 17, 2021
@ijjk
Copy link
Member

ijjk commented Feb 3, 2022

Hi, we've updated jest-worker in the latest versions of Next.js v12.0.10, can anyone who was seeing this behavior confirm this is no longer present after updating Next.js versions?

@markerikson
Copy link
Author

For me the issue was resolved by upgrading from Node 12 to Node 14, per my earlier comment.

@ijjk
Copy link
Member

ijjk commented Feb 3, 2022

Considering this only affected Node.js 12 and it is EOL in a couple months I'm going to close this issue, if anyone is still encountering this on >= v14 of Node.js please create a new issue with additional information to allow investigation!

@ijjk ijjk closed this as completed Feb 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 6, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Webpack Related to Webpack with Next.js.
Projects
None yet
Development

No branches or pull requests

9 participants