Skip to content

Nx Daemon: "Socket closed / EPIPE" and auto-creation of "disabled" file caused by IntelliJ Nx Console background checks #3095

@TZanke

Description

@TZanke

Description
The Nx Daemon repeatedly crashes or disconnects with write EPIPE and Socket closed, eventually leading to the creation of the .nx/workspace-data/d/disabled file. This behavior seems to be triggered by the IntelliJ Nx Console plugin's background status checks, which appear to interfere with the active Daemon socket.

When this happens, subsequent Nx commands run without the daemon, and the only way to recover is to manually delete .nx and/or the disabled file and run npx nx reset.


Environment

  • Nx Version: 22.5.4 (local, from package.json)
  • Node Version: 24.14.0
  • OS: Windows 11
  • IDE: IntelliJ IDEA with Nx Console plugin
  • Daemon: Enabled (default settings)

nx.json (relevant part):

{
  "tasksRunnerOptions": {
    "default": {
      "runner": "nx/tasks-runners/default",
      "options": {
        "cacheableOperations": ["build"],
        "cacheDirectory": ".nx/cache",
        "parallel": 3,
        "useDaemonProcess": true
      }
    }
  }
}

Current Behavior

  1. Nx Daemon starts normally and successfully builds the project graph.

  2. Project graph and cache are written without errors, e.g.:

    [NX v22.5.4 Daemon Server] - ... Wrote project graph cache to ...\.nx\workspace-data\project-graph.json
    [NX v22.5.4 Daemon Server] - Responding to REQUEST_PROJECT_GRAPH message
    [NX v22.5.4 Daemon Server] - [REQUEST]: Responding to the client. project-graph
    [NX v22.5.4 Daemon Client] - [Messenger] Received message, length: 872783
    
  3. After a short time (often ~20–30 seconds), Nx Console in IntelliJ performs a background status check:

    [NX v22.5.4 Daemon Server] - [NX-CONSOLE]: Successfully pulled latest Nx to C:\Users\...\AppData\Local\Temp\tmp-XXXX
    [NX v22.5.4 Daemon Server] - [NX-CONSOLE]: Using local implementation (NX_USE_LOCAL=true or inner call)
    [NX v22.5.4 Daemon Server] - [NX-CONSOLE]: Console status check completed, shouldPrompt: false
    
  4. Shortly after that, the active daemon client reports that the socket was closed and tries to reconnect:

    [NX v22.5.4 Daemon Client] - [ProjectGraphListener] Socket closed, triggering reconnection
    [NX v22.5.4 Daemon Client] - [ProjectGraphListener] Starting reconnection for 1 callbacks
    [NX v22.5.4 Daemon Client] - [Client] Waiting for server (max: 6000 attempts, 10ms interval)
    
  5. In other runs, this is followed by Socket error: write EPIPE messages from the client. After repeated failures, Nx creates a disabled file:

    <project-root>/.nx/workspace-data/d/disabled
    

    Once this file exists, the daemon is no longer used, even if --start is called.


Expected Behavior

  • The IntelliJ Nx Console plugin should not cause the existing daemon connection to be closed or destabilized.
  • Background status checks from Nx Console should not result in Socket closed / EPIPE errors for other daemon clients.
  • The daemon should remain stable while both CLI (npx nx ...) and IntelliJ Nx Console are in use.

Steps to Reproduce

  1. Open workspace in IntelliJ:

    • Open an Nx workspace with nx set to ~22.5.4 in package.json.
    • Ensure the Nx Console plugin for IntelliJ IDEA is installed and enabled.
  2. Clean daemon state:

    • Close all running Node processes that might hold daemon sockets (optional but helps):

      stop-process -name node -force -ErrorAction SilentlyContinue
    • In the workspace root, delete .nx and reset Nx:

      Remove-Item -Recurse -Force .nx
      npx nx reset
  3. Enable verbose logging:

    • Set environment variable:

      $env:NX_VERBOSE_LOGGING = "true"
    • Run a command that uses the daemon, e.g.:

      npx nx graph
    • Confirm that daemon.log is created in:

      <project-root>/.nx/workspace-data/d/daemon.log
      
  4. Trigger Nx Console refresh:

    • In IntelliJ, open the Nx Console tool window.
    • Click the "Refresh" button to refresh the project graph.
  5. Wait and observe logs:

    • Wait ~20–30 seconds.

    • Inspect daemon.log and look for a sequence like:

      [NX v22.5.4 Daemon Server] - Wrote project graph cache to ...\project-graph.json
      [NX v22.5.4 Daemon Server] - Responding to REQUEST_PROJECT_GRAPH message
      [NX v22.5.4 Daemon Client] - [Messenger] Received message, length: 872783
      ...
      [NX v22.5.4 Daemon Server] - [NX-CONSOLE]: Successfully pulled latest Nx to C:\Users\...\Temp\tmp-XXXX
      [NX v22.5.4 Daemon Server] - [NX-CONSOLE]: Using local implementation (NX_USE_LOCAL=true or inner call)
      [NX v22.5.4 Daemon Client] - [ProjectGraphListener] Socket closed, triggering reconnection
      [NX v22.5.4 Daemon Client] - [ProjectGraphListener] Starting reconnection for 1 callbacks
      
  6. Observe failure / disabled file:

    • In some runs, additional errors appear:

      [NX v22.5.4 Daemon Client] - [Messenger] Socket error: write EPIPE
      
    • Check the daemon directory:

      <project-root>/.nx/workspace-data/d/
      
    • A file named disabled will often be present after repeated failures. From that point on, the daemon is not used anymore by default. Image

  7. Control test (without IntelliJ):

    • Close IntelliJ IDEA completely.
    • Delete .nx again and run npx nx reset.
    • Run npx nx graph and leave it running for a while.
    • In this setup, the daemon remains stable and no Socket closed / EPIPE / disabled behavior is observed.

Additional Notes

  • This strongly suggests a race condition or resource conflict between the IntelliJ Nx Console plugin and other daemon clients.
  • The daemon itself appears to function correctly when used solely from the CLI.

  • Optionally: provide clearer logging when the daemon decides to create the disabled file due to IDE-induced failures, so users understand the root cause more easily.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions