Skip to content

Codex spawning multiple node processes that block computer #1570

Closed

Description

@MauScheff

What version of Codex is running?

codex-cli 0.3.0

Which model were you using?

codex-mini-latest

What platform is your computer?

Darwin 24.4.0 x86_64 i386

What steps can reproduce the bug?

Run codex with a complex typescript codebase on full-auto and give long and complex tasks

What is the expected behavior?

Runs smoothly and doesn't break computer. Seems like it's not closing processes. This happens often in the workflow and it's not just a one-off.

What do you see instead?

See image

Additional information

Image Image

Activity

  1. added
    bug
    on Jul 14, 2025
  2. bolinfest commented on Jul 16, 2025

    @bolinfest
    Collaborator

    Out of curiosity, did you install via npm as opposed to brew?

  3. bolinfest commented on Jul 16, 2025

    @bolinfest
    Collaborator

    My hypothesis is that it has something to do with #1590. Will try to look into that today.

  4. MauScheff commented on Jul 17, 2025

    @MauScheff
    Author

    Out of curiosity, did you install via npm as opposed to brew?

    I installed it with brew.

  5. bolinfest commented on Jul 17, 2025

    @bolinfest
    Collaborator

    @MauScheff hmm, OK, then #1590 is not likely the right fix. I do have one other hypothesis...

    But to confirm: do you believe Codex was invoking node as part of its work?

  6. bolinfest commented on Jul 19, 2025

    @bolinfest
    Collaborator

    @MauScheff while I don't believe #1626 will fix your issue since your screenshots appear to be on macOS, can you tell me what those node commands were (i.e., the full argument list)? Or more importantly, were they long-running commands (like tsc --watch) or something else? Is the PPID 1 (the init process) because they were reparented after codex exited?

  7. MauScheff commented on Jul 23, 2025

    @MauScheff
    Author

    I do believe they were spawned by codex, but it could be something else, as that problem happened during a workflow when I was mostly using codex --full-auto on VSCode to work with TypeScript, but it could be something else like VSCode itself (or an extension), and I may have occasionally used Copilot Chat (and that caused the issue) but I used it sparingly (eg. 5% of the time) and I remember having to reset my computer and killing those processes, and this happening again a few times. I was working with a complex typescript codebase, and I always allow codex to go outside the sandbox, so it may have ran some commands. All I have is the screenshots I added from when that happened. It could have been that vscode was running tsc --watch but I'm not sure. I can see that all processes have the same number of threads, this may suggest whomever spawned them was the same actor. I just verified that if I open the same project on VSCode, there is no node process that just runs: eg. a background long running tsc --watch (and I wasn't doing that). The one thing I probably did inadvertently was having multiple running instances of codex (but only one operating at the time).

  8. bolinfest commented on Jul 23, 2025

    @bolinfest
    Collaborator

    @MauScheff thanks for the incredibly detailed report!

    I'm going to start paying more attention to this and have some ideas on how to create the equivalent to #1626 in a way that works on Mac.

  9. MauScheff commented on Jul 23, 2025

    @MauScheff
    Author

    Ahh I see, interesting, I understand what happened now, makes sense. I don't know how you would get around it though. Seems like an OS level problem were parent processes can be killed and the children keep running as if they're disconnected.

  10. ishikawa commented on Aug 9, 2025

    @ishikawa

    I think I’ve encountered a phenomenon similar to what’s described in this issue.

    $ sw_vers
    ProductName:            macOS
    ProductVersion:         15.6
    BuildVersion:           24G84
    $ codex --version
    codex-cli 0.19.0
    

    Steps to reproduce:

    1. Run npm run test via Codex CLI.
      In my case, this script runs vitest run.
    2. While tests are running, check processes via ps aux | grep node.
      You can see multiple node (vitest N) processes.
    3. Exit Codex.
    4. Run ps aux | grep node again — some vitest processes are still alive.

    Example output while Codex was running:

    USER       PID  %CPU %MEM ... COMMAND
    ...  node (vitest 1)
    ...  node (vitest 4)
    ...  node (vitest 7)
    ...  /path/to/esbuild --service=...
    ...  codex-aarch64-apple-darwin --full-auto
    

    After Codex exit (still running):

    USER       PID  %CPU %MEM ... COMMAND
    ...  node (vitest 7)
    ...  node (vitest 3)
    ...  node (vitest 4)
    

    From what I can tell, the remaining processes are child processes spawned by vitest itself. This does not happen when running npm run test directly in a regular terminal — only when run inside Codex.

  11. ishikawa commented on Aug 9, 2025

    @ishikawa

    Additional information for #1570 (comment)

    • This does not reproduce when running inside a sandboxed environment.
    • However, if sandbox execution is denied with EPERM, it may fall back to direct execution (instead of privilege escalation), and in that case the issue reproduces.
    • The remaining processes disappear automatically after some time (around 5 minutes).
  12. 3 remaining items

  13. mettamatt commented on Aug 19, 2025

    @mettamatt
    • Codex v0.22.0 on macOS 15.6
    • Running npm run test (vitest) leaves orphaned node (vitest N) processes
    • Processes remain after Codex exits or times out
    • Each orphaned process consumes ~100% CPU

    Temporary workaround until fixed (at least for my own vitest processes):

    Add to your shell profile (.zshrc or .bashrc)
    alias codex-cleanup='pkill -f "node.*vitest"'

    Looks like what needs to be implemented is some kind of process group management, similar to how shells handle job control with setpgid() and to kill the entire process group on exit.

  14. ichabodcole commented on Sep 6, 2025

    @ichabodcole

    @mettamatt I was able to instruct my agent to run codex-cleanup after every test run it initiates :D

  15. GreatAuk commented on Sep 15, 2025

    @GreatAuk

    +1
    codex 0.34.0
    after run vitest

  16. etraut-openai commented on Nov 2, 2025

    @etraut-openai
    Contributor

    I think the original issue reported here is no longer relevant because the CLI has been completely rewritten in Rust since then. Some of the other issues that were reported in this thread may still be an issue today, but it's hard to say. If you're seeing a similar issue, please open a new bug report and provide repro steps.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions