Skip to content

After Update to nx@21.6.2 (from 20.7.0) Daemon Crashes when running nx between Docker and non-docker #33263

@distante

Description

@distante

Current Behavior

In a project where some NestJS apps are running in a docker container, running nx outside of the container (for example as commit hook for linting) will cause the Daemon to close all connections and crash.

Expected Behavior

nx can be called without killing the existing daemons like was before 21.6.2

GitHub Repo

No response

Steps to Reproduce

  1. Run an standart nestjs application on docker compose (link node_modules and manually install os related dependencies
  2. Run nx report command outside of the docker container

Nx Report

npx nx report

 NX   Report complete - copy this into the issue template

Node           : 20.19.0
OS             : darwin-arm64
Native Target  : aarch64-macos
npm            : 10.8.2

nx                     : 21.6.2
@nx/js                 : 21.6.2
@nx/jest               : 21.6.2
@nx/eslint             : 21.6.2
@nx/workspace          : 21.6.2
@nx/angular            : 21.6.2
@nx/cypress            : 21.6.2
@nx/devkit             : 21.6.2
@nx/esbuild            : 21.6.2
@nx/eslint-plugin      : 21.6.2
@nx/module-federation  : 21.6.2
@nx/nest               : 21.6.2
@nx/node               : 21.6.2
@nx/playwright         : 21.6.2
@nx/plugin             : 21.6.2
@nx/rspack             : 21.6.2
@nx/storybook          : 21.6.2
@nx/web                : 21.6.2
@nx/webpack            : 21.6.2
@nx/docker             : 21.6.2
typescript             : 5.9.3
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/webpack/plugin
---------------------------------------
Community plugins:
@analogjs/platform            : 1.19.4
@analogjs/storybook-angular   : 1.19.4
@analogjs/vite-plugin-angular : 1.19.4
@analogjs/vitest-angular      : 1.19.4
@ionic/angular                : 7.8.6
@ngrx/component-store         : 20.0.1
@ngrx/effects                 : 20.0.1
@ngrx/entity                  : 20.0.1
@ngrx/operators               : 20.0.1
@ngrx/router-store            : 20.0.1
@ngrx/schematics              : 20.0.1
@ngrx/signals                 : 20.0.1
@ngrx/store                   : 20.0.1
@ngrx/store-devtools          : 20.0.1
@nxext/capacitor              : 17.0.1
@nxext/ionic-angular          : 17.0.1
@storybook/angular            : 8.6.14
@testing-library/angular      : 18.0.0
---------------------------------------

---------------------------------------
Cache Usage: 0.00 B / 92.64 GB

Failure Logs

[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.417Z - Closed a connection. Number of open connections: 8
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.418Z - Closed a connection. Number of open connections: 7
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.418Z - Closed a connection. Number of open connections: 6
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.418Z - Closed a connection. Number of open connections: 5
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.418Z - Closed a connection. Number of open connections: 4
6.2 Daemon Server] - 2025-10-27T11:32:29.400Z - Closed a connection. Number of open connections: 1
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.400Z - [REQUEST]: Client Request for Project Graph Received
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.418Z - Closed a connection. Number of open connections: 3
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.418Z - Closed a connection. Number of open connections: 2
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.419Z - Closed a connection. Number of open connections: 1
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.419Z - Closed a connection. Number of open connections: 0
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.419Z - [WATCHER]: Stopping the watcher for /app (sources)
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.419Z - [WATCHER]: Stopping the watcher for /app (outputs)
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.420Z - Server stopped because: "this process is no longer the current daemon (native)"
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.597Z - Started listening on: /app/.nx-docker-daemon-socket/d.sock
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.604Z - [WATCHER]: Subscribed to changes within: /app (native)
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.605Z - Established a connection. Number of open connections: 1
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.606Z - Established a connection. Number of open connections: 2
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.607Z - Closed a connection. Number of open connections: 1
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.607Z - Established a connection. Number of open connections: 2
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.607Z - Closed a connection. Number of open connections: 1
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.607Z - Established a connection. Number of open connections: 2
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.609Z - Started listening on: /app/.nx-docker-daemon-socket/d.sock
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.612Z - [WATCHER]: Subscribed to changes within: /app (native)
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.612Z - [REQUEST]: Responding to the client. handleRecordTaskRuns
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.612Z - Done responding to the client handleRecordTaskRuns
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.612Z - Handled RECORD_TASK_RUNS. Handling time: 4. Response time: 0.
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.614Z - [REQUEST]: Responding to the client. handleRecordTaskRuns
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.614Z - Done responding to the client handleRecordTaskRuns
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.615Z - Handled RECORD_TASK_RUNS. Handling time: 1. Response time: 1.
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.615Z - [REQUEST]: Responding to the client. handleGetFlakyTasks
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.617Z - Done responding to the client handleGetFlakyTasks
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.617Z - Handled GET_FLAKY_TASKS. Handling time: 0. Response time: 2.
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.619Z - [REQUEST]: Responding to the client. handleGetFlakyTasks
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.621Z - Done responding to the client handleGetFlakyTasks
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.621Z - Handled GET_FLAKY_TASKS. Handling time: 0. Response time: 2.
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.622Z - Closed a connection. Number of open connections: 1
[NX v21.6.2 Daemon Server] - 2025-10-27T11:32:29.625Z - Closed a connection. Number of open connections: 0

Package Manager Version

npm

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

It was working as expected before the update to 21.6.2 (we went from 20.7.0). As soon as we do something with nx outside of the docker containers, or enable the Nx Console extensions in our IDEs the docker containers running our NestJS Application APIs Crash or stop listening for changes and we need to restart them.

I tried putting the socket file into another folder using NX_DAEMON_SOCKET_DIR. Neither a shared nor an internal-container folder changed the behavior.
Also tried with NX_NON_NATIVE_HASHER=true

The docker-compose services looks like this:

  client-app-api-local-dev:
    profiles: ["platform", "app-api"]
    container_name: app-api-local
    image: node:20.19.0
    tty: true
    working_dir: /app
    user: ${DOCKER_USER}
    environment:
      - NX_TUI=false
      - CLIENT_PLATFORM_DB_HOST=mariadb-local
      - CLIENT_PLATFORM_DB_PORT=3306
      - CLIENT_PLATFORM_DB_USER=****
      - CLIENT_PLATFORM_DB_PASSWORD=******
      - CLIENT_PLATFORM_DB_NAME=platform
      - CLIENT_PLATFORM_REDIS_HOST=redis-local
      - CLIENT_PLATFORM_REDIS_PORT=6379
      - CLIENT_PLATFORM_REDIS_DB=1
      - CLIENT_REDIS_HOST=redis-local
      - CLIENT_REDIS_PORT=6379
      - CLIENT_REDIS_DB=0
      # issue https://github.com/nrwl/nx/issues/15452
      - NX_NON_NATIVE_HASHER=true
      - MAX_CLUSTER_SIZE=1
      - DATABASE_REPLICA_ACTIVATED=false
      - NX_DAEMON=true
      - NX_DAEMON_SOCKET_DIR=./.nx-docker-daemon-socket

    volumes:
      - ../..:/app
      - ${NPM_CACHE}:/.npm
      - ../../.nx-docker-daemon-socket:/.nx-docker-daemon-socket
    command: bash -c "./tools/scripts/wait-for-it.sh -t 180 mariadb-local:3306 && npm run client:platform:run-migrations && echo 'Starting NX Serve' && npx nx serve client-app-api"
    networks:
      - local-dev-net
    ports:
      - 3334:3334
      - 6661:6661
    depends_on:
      client-mariadb-local-dev:
        condition: service_started
      client-setup:
        condition: service_completed_successfully
    deploy:
      resources:
        limits:
          cpus: "2"
          memory: "3g"

Extra Info

The daemon also dies if we remove some file from the project. 🤷‍♂️

Metadata

Metadata

Assignees

Labels

priority: highHigh Priority (important issues which affect many people severely)scope: corecore nx functionalitytype: bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions