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

exiting a terminal causes 100% cpu usage and breaks restarting that terminal with node >= v18.18 #6963

Open
williamstein opened this issue Oct 5, 2023 · 2 comments

Comments

@williamstein
Copy link
Contributor

williamstein commented Oct 5, 2023

With Node.js v18.18.0 on cocalc-docker (and also cocalc.com) the following steps result in the nodejs hub process getting stuck at 100% making the project almost unusably slow. The following is 100% reproducible on cocalc-docker. It's I think even worse on cocalc.com.

  1. Open a terminal in a CoCalc project and split it in half using the split button.
  2. Run the top command in one frame.
  3. Hit ctrl+d to exit the other frame.
  4. The first time, this works fine. Now restart the project, open the same terminal and do 1-3 again. Every single time, the cpu gets pegged at 100%.
  5. Every time the terminal attempts to start again it fails immediately with "signal 1" (and exit code 0).

Switch to v18.17.1 and the problem goes away entirely.

I noticed a few things when working on this.

io_uring_enter(19, 1, 1, IORING_ENTER_GETEVENTS, NULL, 0) = 1
epoll_pwait(17, [{events=EPOLLHUP, data={u32=38, u64=38}}, {events=EPOLLIN, data={u32=40, u64=40}}], 1024, 0, NULL, 8) = 2
read(40, "read(40, \"read(40, \\\"read(40, \\\\"..., 65536) = 272
writev(36, [{iov_base="\201~\1m", iov_len=4}, {iov_base="[0,\"yw5so45vo29\",\"terminal:.2023"..., iov_len=365}], 2) = 369
  • I have no clue if this post by Jared Sumner about something similar is relevant.
  • Note that v18.18.0 is the next release after 18.17.1, and 18.18.0 was released on Sep 16, 2023.
  • I haven't yet reproduced this bug outside of the complicated environment of "running a cocalc project" (so a daemon, etc.).
  • It's not clear whether this is a bug in node-pty (perhaps the C extension code) or in nodejs itself.

WORKAROUND: Use node v18.17.1.

@williamstein
Copy link
Contributor Author

NOTE: I've now pinned version 18.17.1 of nodejs everywhere, e.g., in the latest cocalc-docker image and on cocalc.com, so this issue is mitigated for now.

@louislam
Copy link

Thanks for the workaround, it saved my time. I also added your name in the release note, because I literally couldn't solve it without seeing your info here.

For your information, I was experiencing this on Node.js 20.10.0.

Instead of the top command, my project runs docker compose start/restart/down commands.

Not sure if it is related, but they are also "interactive terminals". I don't know the exact name of this.

And also it doesn't seem to happen on Windows' Node.js 20.10.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants