@ohos-ports/nx 23.3.0-beta.2 → 24.0.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -6
- package/dist/bin/nx.js +2 -2
- package/dist/bin/post-install.js +5 -3
- package/dist/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +7 -1
- package/dist/src/adapter/ngcli-adapter.js +2 -2
- package/dist/src/ai/clone-ai-config-repo.js +49 -12
- package/dist/src/command-line/add/add.d.ts +2 -0
- package/dist/src/command-line/add/add.js +23 -5
- package/dist/src/command-line/affected/affected.js +2 -2
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +0 -12
- package/dist/src/command-line/graph/graph.js +38 -10
- package/dist/src/command-line/init/command-object.js +0 -12
- package/dist/src/command-line/init/implementation/add-nx-to-nest.js +21 -62
- package/dist/src/command-line/init/init-v2.js +0 -2
- package/dist/src/command-line/migrate/agentic/close-agent-session.d.ts +1 -1
- package/dist/src/command-line/migrate/agentic/close-agent-session.js +4 -3
- package/dist/src/command-line/migrate/agentic/definitions.d.ts +1 -3
- package/dist/src/command-line/migrate/agentic/definitions.js +5 -97
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.d.ts +7 -45
- package/dist/src/command-line/migrate/agentic/handoff-gitignore.js +9 -51
- package/dist/src/command-line/migrate/agentic/handoff.d.ts +1 -43
- package/dist/src/command-line/migrate/agentic/handoff.js +3 -119
- package/dist/src/command-line/migrate/agentic/instruction-files.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/instruction-files.js +6 -27
- package/dist/src/command-line/migrate/agentic/master/run-master-session.d.ts +19 -1
- package/dist/src/command-line/migrate/agentic/master/run-master-session.js +88 -49
- package/dist/src/command-line/migrate/agentic/master/spawn-master.d.ts +1 -0
- package/dist/src/command-line/migrate/agentic/master/spawn-master.js +86 -24
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.d.ts +2 -2
- package/dist/src/command-line/migrate/agentic/print-dropped-agent-context.js +2 -2
- package/dist/src/command-line/migrate/agentic/prompts/fragments.d.ts +1 -12
- package/dist/src/command-line/migrate/agentic/prompts/fragments.js +8 -17
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.d.ts +0 -15
- package/dist/src/command-line/migrate/agentic/prompts/shared-rendering.js +3 -100
- package/dist/src/command-line/migrate/agentic/select.d.ts +12 -6
- package/dist/src/command-line/migrate/agentic/select.js +38 -8
- package/dist/src/command-line/migrate/agentic/types.d.ts +9 -68
- package/dist/src/command-line/migrate/agentic/types.js +6 -8
- package/dist/src/command-line/migrate/command-object.js +6 -10
- package/dist/src/command-line/migrate/execute-migration.d.ts +6 -6
- package/dist/src/command-line/migrate/execute-migration.js +25 -15
- package/dist/src/command-line/migrate/migrate-analytics.d.ts +18 -1
- package/dist/src/command-line/migrate/migrate-analytics.js +38 -0
- package/dist/src/command-line/migrate/migrate-commits.d.ts +29 -17
- package/dist/src/command-line/migrate/migrate-commits.js +86 -32
- package/dist/src/command-line/migrate/migrate-config.d.ts +6 -6
- package/dist/src/command-line/migrate/migrate-config.js +12 -6
- package/dist/src/command-line/migrate/migrate-output.d.ts +1 -6
- package/dist/src/command-line/migrate/migrate-output.js +1 -10
- package/dist/src/command-line/migrate/migrate.d.ts +6 -30
- package/dist/src/command-line/migrate/migrate.js +257 -255
- package/dist/src/command-line/migrate/resolve-package-version.d.ts +2 -4
- package/dist/src/command-line/migrate/resolve-package-version.js +2 -35
- package/dist/src/command-line/migrate/run/agent-output.d.ts +2 -0
- package/dist/src/command-line/migrate/run/agent-output.js +9 -0
- package/dist/src/command-line/migrate/run/broker.d.ts +14 -5
- package/dist/src/command-line/migrate/run/broker.js +69 -21
- package/dist/src/command-line/migrate/run/clean-retry.js +4 -2
- package/dist/src/command-line/migrate/run/existing-run-report.d.ts +1 -1
- package/dist/src/command-line/migrate/run/existing-run-report.js +7 -5
- package/dist/src/command-line/migrate/run/give-up.d.ts +4 -3
- package/dist/src/command-line/migrate/run/give-up.js +8 -5
- package/dist/src/command-line/migrate/run/index.d.ts +7 -5
- package/dist/src/command-line/migrate/run/index.js +16 -1
- package/dist/src/command-line/migrate/run/issues.js +7 -2
- package/dist/src/command-line/migrate/run/orchestrator.d.ts +61 -4
- package/dist/src/command-line/migrate/run/orchestrator.js +397 -133
- package/dist/src/command-line/migrate/run/run-state.d.ts +17 -1
- package/dist/src/command-line/migrate/run/run-state.js +41 -2
- package/dist/src/command-line/migrate/run/runbook.d.ts +1 -0
- package/dist/src/command-line/migrate/run/runbook.js +115 -18
- package/dist/src/command-line/migrate/run/state-lock.d.ts +29 -4
- package/dist/src/command-line/migrate/run/state-lock.js +102 -10
- package/dist/src/command-line/migrate/run/state-machine.js +4 -1
- package/dist/src/command-line/migrate/run/util.d.ts +7 -2
- package/dist/src/command-line/migrate/run/util.js +30 -3
- package/dist/src/command-line/migrate/run/worker.d.ts +1 -1
- package/dist/src/command-line/migrate/run/worker.js +252 -250
- package/dist/src/command-line/migrate/sort-migrations.d.ts +1 -7
- package/dist/src/command-line/migrate/sort-migrations.js +1 -12
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -12
- package/dist/src/command-line/release/changelog.js +9 -6
- package/dist/src/command-line/release/config/config.d.ts +1 -0
- package/dist/src/command-line/release/config/config.js +48 -9
- package/dist/src/command-line/release/release.js +2 -2
- package/dist/src/command-line/release/utils/git.js +8 -7
- package/dist/src/command-line/release/utils/interpolate-release-config.d.ts +6 -0
- package/dist/src/command-line/release/utils/interpolate-release-config.js +39 -0
- package/dist/src/command-line/release/utils/release-graph.d.ts +5 -0
- package/dist/src/command-line/release/utils/release-graph.js +1 -0
- package/dist/src/command-line/release/utils/remote-release-clients/github.js +5 -6
- package/dist/src/command-line/release/utils/remote-release-clients/gitlab.js +5 -6
- package/dist/src/command-line/release/utils/resolve-changelog-renderer.js +2 -2
- package/dist/src/command-line/release/utils/shared.js +10 -10
- package/dist/src/command-line/release/utils/version-plan-utils.d.ts +3 -12
- package/dist/src/command-line/release/utils/version-plan-utils.js +33 -55
- package/dist/src/command-line/release/version/version-actions.js +2 -1
- package/dist/src/command-line/release/version.js +5 -2
- package/dist/src/command-line/reset/reset.js +58 -62
- package/dist/src/command-line/run/executor-utils.js +1 -0
- package/dist/src/command-line/run/run-one.d.ts +20 -1
- package/dist/src/command-line/run/run-one.js +153 -5
- package/dist/src/command-line/run/run.js +2 -1
- package/dist/src/command-line/show/projects.js +5 -3
- package/dist/src/command-line/show/show-target/info.d.ts +10 -1
- package/dist/src/command-line/show/show-target/info.js +100 -15
- package/dist/src/command-line/show/show-target/inputs.js +10 -2
- package/dist/src/command-line/show/show-target/utils.js +1 -0
- package/dist/src/command-line/watch/command-object.js +3 -22
- package/dist/src/command-line/watch/watch.d.ts +0 -7
- package/dist/src/command-line/watch/watch.js +1 -1
- package/dist/src/command-line/yargs-utils/shared-options.js +1 -1
- package/dist/src/config/misc-interfaces.d.ts +18 -0
- package/dist/src/config/nx-json.d.ts +22 -11
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +88 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/core/graph/runtime.js +1 -1
- package/dist/src/core/graph/styles.css +1 -1
- package/dist/src/core/graph/styles.js +1 -1
- package/dist/src/daemon/client/client.d.ts +15 -0
- package/dist/src/daemon/client/client.js +181 -71
- package/dist/src/daemon/client/daemon-socket-messenger.d.ts +1 -1
- package/dist/src/daemon/client/daemon-socket-messenger.js +2 -2
- package/dist/src/daemon/server/client-socket-context.js +1 -1
- package/dist/src/daemon/server/handle-process-in-background.js +21 -9
- package/dist/src/daemon/server/handle-select-affected-tasks.d.ts +2 -1
- package/dist/src/daemon/server/handle-select-affected-tasks.js +21 -13
- package/dist/src/daemon/server/native-js-loader.d.ts +1 -0
- package/dist/src/daemon/server/native-js-loader.js +21 -0
- package/dist/src/daemon/server/project-graph-incremental-recomputation.js +4 -8
- package/dist/src/daemon/server/server.d.ts +2 -1
- package/dist/src/daemon/server/server.js +17 -4
- package/dist/src/daemon/server/shutdown-utils.js +0 -3
- package/dist/src/daemon/server/start.d.ts +1 -0
- package/dist/src/daemon/server/start.js +2 -0
- package/dist/src/daemon/socket-utils.d.ts +11 -9
- package/dist/src/daemon/socket-utils.js +31 -61
- package/dist/src/daemon/tmp-dir.d.ts +19 -14
- package/dist/src/daemon/tmp-dir.js +142 -354
- package/dist/src/devkit-exports.d.ts +9 -1
- package/dist/src/devkit-exports.js +12 -1
- package/dist/src/devkit-internals.d.ts +6 -5
- package/dist/src/devkit-internals.js +13 -4
- package/dist/src/executors/run-commands/run-commands.impl.d.ts +4 -2
- package/dist/src/executors/run-commands/run-commands.impl.js +53 -27
- package/dist/src/executors/run-commands/running-tasks.d.ts +13 -4
- package/dist/src/executors/run-commands/running-tasks.js +148 -95
- package/dist/src/executors/run-commands/schema.json +1 -1
- package/dist/src/hasher/check-task-files.js +5 -8
- package/dist/src/hasher/file-hasher.js +9 -7
- package/dist/src/hasher/hash-task.js +4 -0
- package/dist/src/hasher/native-task-hasher-impl.js +3 -1
- package/dist/src/hasher/task-hasher.d.ts +2 -0
- package/dist/src/hasher/task-hasher.js +4 -1
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.d.ts +1 -2
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.js +6 -11
- package/dist/src/migrations/update-23-2-0/set-cache-on-executor-target-defaults.md +2 -2
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.d.ts +4 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.js +15 -0
- package/dist/src/migrations/update-24-0-0/enable-legacy-affected.md +30 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.js +100 -0
- package/dist/src/migrations/update-24-0-0/find-custom-hashers.md +63 -0
- package/dist/src/migrations/update-24-0-0/move-custom-hashers-to-inputs.md +146 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.d.ts +3 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.js +130 -0
- package/dist/src/migrations/update-24-0-0/rename-ultracache-ignore-options.md +62 -0
- package/dist/src/native/assert-supported-platform.js +1 -1
- package/dist/src/native/index.d.ts +238 -18
- package/dist/src/native/index.js +6 -1
- package/dist/src/native/native-bindings.js +15 -6
- package/dist/src/native/nx.openharmony-arm64.node +0 -0
- package/dist/src/native/nx.wasi-browser.js +1 -0
- package/dist/src/native/nx.wasi.cjs +1 -0
- package/dist/src/native/nx.wasm32-wasi.debug.wasm +0 -0
- package/dist/src/native/nx.wasm32-wasi.wasm +0 -0
- package/dist/src/nx-cloud/update-manager.d.ts +14 -0
- package/dist/src/nx-cloud/update-manager.js +237 -50
- package/dist/src/plugins/js/lock-file/pnpm-parser.js +3 -4
- package/dist/src/plugins/js/lock-file/pruned-output.d.ts +2 -2
- package/dist/src/plugins/js/lock-file/pruned-output.js +4 -4
- package/dist/src/plugins/js/utils/register.js +9 -4
- package/dist/src/project-graph/affected/affected-tasks.d.ts +9 -6
- package/dist/src/project-graph/affected/affected-tasks.js +31 -7
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +7 -0
- package/dist/src/project-graph/plugins/loaded-nx-plugin.js +49 -6
- package/dist/src/project-graph/utils/project-configuration/target-merging.js +1 -1
- package/dist/src/project-graph/utils/project-configuration/target-normalization.js +12 -133
- package/dist/src/project-graph/utils/project-configuration-utils.js +2 -2
- package/dist/src/project-graph/utils/retrieve-workspace-files.js +27 -6
- package/dist/src/tasks-runner/create-task-graph.d.ts +8 -7
- package/dist/src/tasks-runner/create-task-graph.js +50 -27
- package/dist/src/tasks-runner/default-tasks-runner.js +1 -1
- package/dist/src/tasks-runner/init-tasks-runner.js +116 -59
- package/dist/src/tasks-runner/life-cycle.d.ts +4 -1
- package/dist/src/tasks-runner/life-cycle.js +7 -0
- package/dist/src/tasks-runner/life-cycles/performance-analysis.d.ts +5 -2
- package/dist/src/tasks-runner/life-cycles/performance-analysis.js +13 -7
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.d.ts +4 -3
- package/dist/src/tasks-runner/life-cycles/performance-life-cycle.js +9 -2
- package/dist/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.js +5 -2
- package/dist/src/tasks-runner/life-cycles/static-run-one-terminal-output-life-cycle.js +4 -1
- package/dist/src/tasks-runner/life-cycles/summary-terminal-output-life-cycle.js +5 -1
- package/dist/src/tasks-runner/pseudo-ipc.d.ts +1 -0
- package/dist/src/tasks-runner/pseudo-ipc.js +4 -0
- package/dist/src/tasks-runner/pseudo-terminal.d.ts +1 -1
- package/dist/src/tasks-runner/pseudo-terminal.js +2 -2
- package/dist/src/tasks-runner/readiness/executor-ready-signal.d.ts +7 -0
- package/dist/src/tasks-runner/readiness/executor-ready-signal.js +43 -0
- package/dist/src/tasks-runner/readiness/probes.d.ts +14 -0
- package/dist/src/tasks-runner/readiness/probes.js +101 -0
- package/dist/src/tasks-runner/readiness/ready-signal-server.d.ts +18 -0
- package/dist/src/tasks-runner/readiness/ready-signal-server.js +72 -0
- package/dist/src/tasks-runner/readiness/ready-signal.d.ts +33 -0
- package/dist/src/tasks-runner/readiness/ready-signal.js +92 -0
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +84 -0
- package/dist/src/tasks-runner/readiness/ready-when.js +371 -0
- package/dist/src/tasks-runner/readiness/startup-host.d.ts +1 -0
- package/dist/src/tasks-runner/readiness/startup-host.js +32 -0
- package/dist/src/tasks-runner/run-command.d.ts +6 -2
- package/dist/src/tasks-runner/run-command.js +21 -31
- package/dist/src/tasks-runner/run-outcome.d.ts +16 -0
- package/dist/src/tasks-runner/run-outcome.js +39 -0
- package/dist/src/tasks-runner/running-tasks/batch-process.js +6 -0
- package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -4
- package/dist/src/tasks-runner/running-tasks/running-task.d.ts +1 -1
- package/dist/src/tasks-runner/task-env.d.ts +10 -0
- package/dist/src/tasks-runner/task-env.js +37 -5
- package/dist/src/tasks-runner/task-graph-utils.d.ts +9 -6
- package/dist/src/tasks-runner/task-graph-utils.js +17 -12
- package/dist/src/tasks-runner/task-orchestrator.d.ts +62 -18
- package/dist/src/tasks-runner/task-orchestrator.js +750 -150
- package/dist/src/tasks-runner/tasks-runner.d.ts +1 -1
- package/dist/src/tasks-runner/tasks-schedule.d.ts +18 -1
- package/dist/src/tasks-runner/tasks-schedule.js +63 -6
- package/dist/src/tasks-runner/tokens.d.ts +54 -0
- package/dist/src/tasks-runner/tokens.js +161 -0
- package/dist/src/tasks-runner/utils.d.ts +35 -6
- package/dist/src/tasks-runner/utils.js +149 -68
- package/dist/src/ultracache/ci-status.d.ts +24 -0
- package/dist/src/ultracache/ci-status.js +87 -0
- package/dist/src/ultracache/config.d.ts +3 -3
- package/dist/src/ultracache/config.js +4 -4
- package/dist/src/ultracache/fetch.d.ts +2 -0
- package/dist/src/ultracache/fetch.js +1 -0
- package/dist/src/ultracache/overrides.js +4 -0
- package/dist/src/utils/acknowledge-build-scripts.d.ts +34 -1
- package/dist/src/utils/acknowledge-build-scripts.js +171 -32
- package/dist/src/utils/child-process.js +2 -1
- package/dist/src/utils/find-matching-projects.js +9 -6
- package/dist/src/utils/git-utils.d.ts +12 -5
- package/dist/src/utils/git-utils.js +69 -11
- package/dist/src/utils/long-running-target.d.ts +1 -3
- package/dist/src/utils/long-running-target.js +1 -3
- package/dist/src/utils/output.d.ts +4 -3
- package/dist/src/utils/output.js +4 -3
- package/dist/src/utils/owned-private-dir.d.ts +1 -17
- package/dist/src/utils/owned-private-dir.js +10 -62
- package/dist/src/utils/package-manager.d.ts +8 -0
- package/dist/src/utils/package-manager.js +65 -8
- package/dist/src/utils/perf-hooks.d.ts +1 -0
- package/dist/src/utils/plugins/core-plugins.js +5 -1
- package/dist/src/utils/progress-topics.d.ts +1 -0
- package/dist/src/utils/progress-topics.js +1 -0
- package/dist/src/utils/safe-spawn.js +1 -5
- package/dist/src/utils/shell-quoting.d.ts +8 -1
- package/dist/src/utils/shell-quoting.js +12 -1
- package/dist/src/utils/spawn-without-terminal.d.ts +27 -0
- package/dist/src/utils/spawn-without-terminal.js +110 -0
- package/dist/src/utils/string-similarity.d.ts +38 -0
- package/dist/src/utils/string-similarity.js +108 -0
- package/migrations.json +20 -6
- package/package.json +15 -24
- package/schemas/migrations-schema.json +11 -0
- package/schemas/nx-schema.json +133 -11
- package/schemas/project-schema.json +114 -4
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.d.ts +0 -56
- package/dist/src/command-line/migrate/agentic/prompts/generic-validation.js +0 -67
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.d.ts +0 -49
- package/dist/src/command-line/migrate/agentic/prompts/hybrid-prompt-migration.js +0 -53
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.d.ts +0 -26
- package/dist/src/command-line/migrate/agentic/prompts/prompt-migration.js +0 -27
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.d.ts +0 -70
- package/dist/src/command-line/migrate/agentic/prompts/system-prompt.js +0 -113
- package/dist/src/command-line/migrate/agentic/run-step.d.ts +0 -68
- package/dist/src/command-line/migrate/agentic/run-step.js +0 -148
- package/dist/src/command-line/migrate/agentic/runner.d.ts +0 -21
- package/dist/src/command-line/migrate/agentic/runner.js +0 -262
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.d.ts +0 -9
- package/dist/src/migrations/update-23-0-0/consolidate-release-tag-config.js +0 -18
- package/dist/src/tasks-runner/legacy-depends-on-warning.d.ts +0 -18
- package/dist/src/tasks-runner/legacy-depends-on-warning.js +0 -109
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.daemonClient = exports.DaemonClient = exports.WatcherFailedError = void 0;
|
|
3
|
+
exports.daemonClient = exports.DaemonClient = exports.WatcherFailedError = exports.DaemonStatus = void 0;
|
|
4
4
|
exports.isDaemonEnabled = isDaemonEnabled;
|
|
5
5
|
exports.daemonPermissionException = daemonPermissionException;
|
|
6
6
|
exports.daemonProcessException = daemonProcessException;
|
|
@@ -55,7 +55,7 @@ var DaemonStatus;
|
|
|
55
55
|
DaemonStatus[DaemonStatus["CONNECTING"] = 0] = "CONNECTING";
|
|
56
56
|
DaemonStatus[DaemonStatus["DISCONNECTED"] = 1] = "DISCONNECTED";
|
|
57
57
|
DaemonStatus[DaemonStatus["CONNECTED"] = 2] = "CONNECTED";
|
|
58
|
-
})(DaemonStatus || (DaemonStatus = {}));
|
|
58
|
+
})(DaemonStatus || (exports.DaemonStatus = DaemonStatus = {}));
|
|
59
59
|
const WAIT_FOR_SERVER_CONFIG = {
|
|
60
60
|
delayMs: 10,
|
|
61
61
|
maxAttempts: 6000, // 6000 * 10ms = 60 seconds
|
|
@@ -95,8 +95,12 @@ class DaemonClient {
|
|
|
95
95
|
this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
96
96
|
this._waitForDaemonReady = null;
|
|
97
97
|
this._daemonReady = null;
|
|
98
|
+
this._daemonReadyFailed = null;
|
|
99
|
+
// Terminal once set — see `handleConnectionError`.
|
|
100
|
+
this._pluginWorkerConnectionLost = null;
|
|
98
101
|
this.fileWatcherReconnecting = false;
|
|
99
102
|
this.fileWatcherFramingFailures = 0;
|
|
103
|
+
this.fileWatcherRegistrations = new Map();
|
|
100
104
|
this.fileWatcherCallbacks = new Map();
|
|
101
105
|
this.fileWatcherConfigs = new Map();
|
|
102
106
|
this.projectGraphListenerReconnecting = false;
|
|
@@ -153,6 +157,7 @@ class DaemonClient {
|
|
|
153
157
|
return this._enabled;
|
|
154
158
|
}
|
|
155
159
|
reset() {
|
|
160
|
+
this.rejectFileWatcherRegistrations(new Error('Daemon client reset'));
|
|
156
161
|
this.socketMessenger?.close();
|
|
157
162
|
this.socketMessenger = null;
|
|
158
163
|
this.queue = new promised_based_queue_1.PromisedBasedQueue();
|
|
@@ -166,7 +171,26 @@ class DaemonClient {
|
|
|
166
171
|
this.projectGraphListenerMessenger?.close();
|
|
167
172
|
this.projectGraphListenerMessenger = undefined;
|
|
168
173
|
this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
169
|
-
this.
|
|
174
|
+
this._pluginWorkerConnectionLost = null;
|
|
175
|
+
this._waitForDaemonReady = this.createReadyPromise();
|
|
176
|
+
}
|
|
177
|
+
createReadyPromise() {
|
|
178
|
+
const promise = new Promise((resolve, reject) => {
|
|
179
|
+
this._daemonReady = resolve;
|
|
180
|
+
this._daemonReadyFailed = reject;
|
|
181
|
+
});
|
|
182
|
+
// Callers don't always await — swallow the unhandled-rejection warning
|
|
183
|
+
// so a rejected ready promise that no one observes doesn't crash the
|
|
184
|
+
// process. Real awaiters still see the rejection.
|
|
185
|
+
promise.catch(() => { });
|
|
186
|
+
return promise;
|
|
187
|
+
}
|
|
188
|
+
// Move out of CONNECTING and surface an error to every caller parked on
|
|
189
|
+
// `_waitForDaemonReady`. Without this, a failure while CONNECTING leaves
|
|
190
|
+
// concurrent callers waiting on a promise that will never settle.
|
|
191
|
+
failDaemonReady(err) {
|
|
192
|
+
this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
193
|
+
this._daemonReadyFailed?.(err);
|
|
170
194
|
}
|
|
171
195
|
getSocketPath() {
|
|
172
196
|
const daemonProcessJson = (0, cache_1.readDaemonProcessJsonCache)();
|
|
@@ -182,12 +206,8 @@ class DaemonClient {
|
|
|
182
206
|
}
|
|
183
207
|
async getProjectGraphAndSourceMaps() {
|
|
184
208
|
(0, project_graph_1.preventRecursionInGraphConstruction)();
|
|
185
|
-
let spinner;
|
|
186
|
-
// If the graph takes a while to load, we want to show a spinner.
|
|
187
|
-
spinner = new delayed_spinner_1.DelayedSpinner('Calculating the project graph on the Nx Daemon');
|
|
188
|
-
this.currentSpinner = spinner;
|
|
189
209
|
try {
|
|
190
|
-
const response = await this.
|
|
210
|
+
const response = await this.sendWithGraphSpinner({
|
|
191
211
|
type: 'REQUEST_PROJECT_GRAPH',
|
|
192
212
|
});
|
|
193
213
|
return {
|
|
@@ -203,10 +223,6 @@ class DaemonClient {
|
|
|
203
223
|
throw e;
|
|
204
224
|
}
|
|
205
225
|
}
|
|
206
|
-
finally {
|
|
207
|
-
spinner?.cleanup();
|
|
208
|
-
this.currentSpinner = null;
|
|
209
|
-
}
|
|
210
226
|
}
|
|
211
227
|
async getAllFileData() {
|
|
212
228
|
return await this.sendToDaemonViaQueue({ type: 'REQUEST_FILE_DATA' });
|
|
@@ -249,16 +265,15 @@ class DaemonClient {
|
|
|
249
265
|
}
|
|
250
266
|
// Generate unique ID for this callback
|
|
251
267
|
const callbackId = Math.random().toString(36).substring(2, 11);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
268
|
+
await this.queue
|
|
269
|
+
.sendToQueue(async () => {
|
|
270
|
+
// Only registrations whose queue entry has started belong to this
|
|
271
|
+
// connection. A failed earlier entry must not reconnect a queued one.
|
|
272
|
+
this.fileWatcherCallbacks.set(callbackId, callback);
|
|
273
|
+
this.fileWatcherConfigs.set(callbackId, config);
|
|
256
274
|
// If we already have a connection, just register the new config
|
|
257
275
|
if (this.fileWatcherMessenger) {
|
|
258
|
-
this.
|
|
259
|
-
type: 'REGISTER_FILE_WATCHER',
|
|
260
|
-
config,
|
|
261
|
-
});
|
|
276
|
+
await this.sendFileWatcherRegistration(callbackId);
|
|
262
277
|
return;
|
|
263
278
|
}
|
|
264
279
|
await this.startDaemonIfNecessary();
|
|
@@ -266,6 +281,8 @@ class DaemonClient {
|
|
|
266
281
|
this.fileWatcherMessenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => {
|
|
267
282
|
try {
|
|
268
283
|
const parsedMessage = (0, consume_messages_from_socket_1.parseMessage)(message);
|
|
284
|
+
if (this.handleFileWatcherRegistration(parsedMessage))
|
|
285
|
+
return;
|
|
269
286
|
// A delivered message means the stream is healthy again.
|
|
270
287
|
this.fileWatcherFramingFailures = 0;
|
|
271
288
|
if (parsedMessage?.watcherError) {
|
|
@@ -289,6 +306,7 @@ class DaemonClient {
|
|
|
289
306
|
// Connection closed - trigger reconnection
|
|
290
307
|
logger_1.clientLogger.log(`[FileWatcher] Socket closed, triggering reconnection`);
|
|
291
308
|
this.fileWatcherMessenger = undefined;
|
|
309
|
+
this.rejectFileWatcherRegistrations(new Error('Daemon disconnected before watcher registration completed'));
|
|
292
310
|
for (const cb of this.fileWatcherCallbacks.values()) {
|
|
293
311
|
cb('reconnecting', null);
|
|
294
312
|
}
|
|
@@ -310,10 +328,12 @@ class DaemonClient {
|
|
|
310
328
|
// failure would otherwise leave this channel silent forever.
|
|
311
329
|
this.fileWatcherMessenger?.close();
|
|
312
330
|
});
|
|
313
|
-
this.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
331
|
+
await this.sendFileWatcherRegistration(callbackId);
|
|
332
|
+
})
|
|
333
|
+
.catch((error) => {
|
|
334
|
+
this.fileWatcherCallbacks.delete(callbackId);
|
|
335
|
+
this.fileWatcherConfigs.delete(callbackId);
|
|
336
|
+
throw error;
|
|
317
337
|
});
|
|
318
338
|
// Return unregister function
|
|
319
339
|
return () => {
|
|
@@ -326,6 +346,52 @@ class DaemonClient {
|
|
|
326
346
|
}
|
|
327
347
|
};
|
|
328
348
|
}
|
|
349
|
+
sendFileWatcherRegistration(callbackId) {
|
|
350
|
+
return new Promise((resolve, reject) => {
|
|
351
|
+
const cleanup = () => {
|
|
352
|
+
clearTimeout(timeout);
|
|
353
|
+
this.fileWatcherRegistrations.delete(callbackId);
|
|
354
|
+
};
|
|
355
|
+
const fail = (error) => {
|
|
356
|
+
cleanup();
|
|
357
|
+
this.fileWatcherCallbacks.delete(callbackId);
|
|
358
|
+
this.fileWatcherConfigs.delete(callbackId);
|
|
359
|
+
reject(error);
|
|
360
|
+
if (this.fileWatcherCallbacks.size === 0) {
|
|
361
|
+
this.fileWatcherMessenger?.close();
|
|
362
|
+
}
|
|
363
|
+
};
|
|
364
|
+
const timeout = setTimeout(() => fail(new Error('Timed out waiting for daemon watcher registration')), WAIT_FOR_SERVER_CONFIG.maxAttempts * WAIT_FOR_SERVER_CONFIG.delayMs);
|
|
365
|
+
this.fileWatcherRegistrations.set(callbackId, {
|
|
366
|
+
resolve: () => {
|
|
367
|
+
cleanup();
|
|
368
|
+
resolve();
|
|
369
|
+
},
|
|
370
|
+
reject: fail,
|
|
371
|
+
});
|
|
372
|
+
try {
|
|
373
|
+
this.fileWatcherMessenger.sendMessage({
|
|
374
|
+
type: 'REGISTER_FILE_WATCHER',
|
|
375
|
+
config: this.fileWatcherConfigs.get(callbackId),
|
|
376
|
+
registrationId: callbackId,
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
catch (error) {
|
|
380
|
+
fail(error);
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
handleFileWatcherRegistration(message) {
|
|
385
|
+
if (message?.type !== 'FILE_WATCHER_REGISTERED')
|
|
386
|
+
return false;
|
|
387
|
+
this.fileWatcherRegistrations.get(message.registrationId)?.resolve();
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
390
|
+
rejectFileWatcherRegistrations(error) {
|
|
391
|
+
for (const registration of [...this.fileWatcherRegistrations.values()]) {
|
|
392
|
+
registration.reject(error);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
329
395
|
async reconnectFileWatcher() {
|
|
330
396
|
// Guard against concurrent reconnection attempts
|
|
331
397
|
if (this.fileWatcherReconnecting) {
|
|
@@ -380,6 +446,8 @@ class DaemonClient {
|
|
|
380
446
|
this.fileWatcherMessenger = new daemon_socket_messenger_1.DaemonSocketMessenger((0, net_1.connect)(socketPath)).listen((message) => {
|
|
381
447
|
try {
|
|
382
448
|
const parsedMessage = (0, consume_messages_from_socket_1.parseMessage)(message);
|
|
449
|
+
if (this.handleFileWatcherRegistration(parsedMessage))
|
|
450
|
+
return;
|
|
383
451
|
// A delivered message means the stream is healthy again.
|
|
384
452
|
this.fileWatcherFramingFailures = 0;
|
|
385
453
|
for (const cb of this.fileWatcherCallbacks.values()) {
|
|
@@ -394,6 +462,7 @@ class DaemonClient {
|
|
|
394
462
|
}, () => {
|
|
395
463
|
// Connection closed - trigger reconnection again
|
|
396
464
|
this.fileWatcherMessenger = undefined;
|
|
465
|
+
this.rejectFileWatcherRegistrations(new Error('Daemon disconnected before watcher registration completed'));
|
|
397
466
|
// Reset reconnection flag before triggering reconnection
|
|
398
467
|
this.fileWatcherReconnecting = false;
|
|
399
468
|
for (const cb of this.fileWatcherCallbacks.values()) {
|
|
@@ -615,10 +684,7 @@ class DaemonClient {
|
|
|
615
684
|
type: 'PROCESS_IN_BACKGROUND',
|
|
616
685
|
requirePath,
|
|
617
686
|
data,
|
|
618
|
-
}
|
|
619
|
-
// This method is sometimes passed data that cannot be serialized with v8
|
|
620
|
-
// so we force JSON serialization here
|
|
621
|
-
'json');
|
|
687
|
+
});
|
|
622
688
|
}
|
|
623
689
|
recordOutputsHashBatch(entries) {
|
|
624
690
|
return this.sendToDaemonViaQueue({
|
|
@@ -736,7 +802,7 @@ class DaemonClient {
|
|
|
736
802
|
type: select_affected_tasks_1.SELECT_AFFECTED_TASKS,
|
|
737
803
|
request,
|
|
738
804
|
};
|
|
739
|
-
return this.
|
|
805
|
+
return this.sendWithGraphSpinner(message);
|
|
740
806
|
}
|
|
741
807
|
updateWorkspaceContext(createdFiles, updatedFiles, deletedFiles) {
|
|
742
808
|
const message = {
|
|
@@ -821,33 +887,50 @@ class DaemonClient {
|
|
|
821
887
|
return (await this.probeServer()).available;
|
|
822
888
|
}
|
|
823
889
|
async startDaemonIfNecessary() {
|
|
890
|
+
if (this._pluginWorkerConnectionLost) {
|
|
891
|
+
throw this._pluginWorkerConnectionLost;
|
|
892
|
+
}
|
|
824
893
|
if (this._daemonStatus == DaemonStatus.CONNECTED) {
|
|
825
894
|
return;
|
|
826
895
|
}
|
|
827
896
|
// Ensure daemon is running and socket path is available
|
|
828
897
|
if (this._daemonStatus == DaemonStatus.DISCONNECTED) {
|
|
898
|
+
// Create a fresh ready promise for any concurrent caller that hits
|
|
899
|
+
// the CONNECTING branch below before this attempt resolves.
|
|
900
|
+
this._waitForDaemonReady = this.createReadyPromise();
|
|
829
901
|
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
830
902
|
let daemonPid = null;
|
|
831
|
-
let probe;
|
|
832
903
|
try {
|
|
833
|
-
probe
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
// Version mismatch - treat as server not available, start new one
|
|
837
|
-
if (err instanceof daemon_socket_messenger_1.VersionMismatchError) {
|
|
838
|
-
probe = { available: false };
|
|
904
|
+
let probe;
|
|
905
|
+
try {
|
|
906
|
+
probe = await this.probeServer();
|
|
839
907
|
}
|
|
840
|
-
|
|
841
|
-
|
|
908
|
+
catch (err) {
|
|
909
|
+
// Version mismatch - treat as server not available, start new one
|
|
910
|
+
if (err instanceof daemon_socket_messenger_1.VersionMismatchError) {
|
|
911
|
+
probe = { available: false };
|
|
912
|
+
}
|
|
913
|
+
else {
|
|
914
|
+
throw err;
|
|
915
|
+
}
|
|
842
916
|
}
|
|
917
|
+
if (!probe.available) {
|
|
918
|
+
// Carried as a value so no other caller's probe can substitute for it.
|
|
919
|
+
daemonPid = await this.startInBackground(probe.refusal);
|
|
920
|
+
}
|
|
921
|
+
this.setUpConnection();
|
|
922
|
+
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
923
|
+
this._daemonReady();
|
|
843
924
|
}
|
|
844
|
-
|
|
845
|
-
//
|
|
846
|
-
|
|
925
|
+
catch (err) {
|
|
926
|
+
// Reset to DISCONNECTED and reject the ready promise so every
|
|
927
|
+
// concurrent caller parked on the CONNECTING branch gets the
|
|
928
|
+
// error instead of hanging forever.
|
|
929
|
+
this.failDaemonReady(err);
|
|
930
|
+
throw err;
|
|
847
931
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
this._daemonReady();
|
|
932
|
+
// Outside the try: the connection is established by now, and a throw
|
|
933
|
+
// from here must not undo it.
|
|
851
934
|
daemonPid ??= (0, cache_1.getDaemonProcessIdSync)();
|
|
852
935
|
// Fire-and-forget - don't block daemon connection by waiting for metrics registration
|
|
853
936
|
this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
@@ -859,13 +942,27 @@ class DaemonClient {
|
|
|
859
942
|
this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
860
943
|
}
|
|
861
944
|
}
|
|
862
|
-
|
|
945
|
+
/** Shows the daemon's streamed graph and selection progress while waiting. */
|
|
946
|
+
async sendWithGraphSpinner(messageToDaemon) {
|
|
947
|
+
const spinner = new delayed_spinner_1.DelayedSpinner('Calculating the project graph on the Nx Daemon');
|
|
948
|
+
try {
|
|
949
|
+
return await this.sendToDaemonViaQueue(messageToDaemon, spinner);
|
|
950
|
+
}
|
|
951
|
+
finally {
|
|
952
|
+
spinner.cleanup();
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
async sendToDaemonViaQueue(messageToDaemon, spinner) {
|
|
863
956
|
return this.queue.sendToQueue(async () => {
|
|
864
|
-
// Set
|
|
865
|
-
//
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
957
|
+
// Set inside the queued function so a waiting request cannot take
|
|
958
|
+
// over the in-flight request's spinner.
|
|
959
|
+
this.currentSpinner = spinner ?? null;
|
|
960
|
+
try {
|
|
961
|
+
return await this.sendMessageToDaemon(messageToDaemon);
|
|
962
|
+
}
|
|
963
|
+
finally {
|
|
964
|
+
this.currentSpinner = null;
|
|
965
|
+
}
|
|
869
966
|
});
|
|
870
967
|
}
|
|
871
968
|
setUpConnection() {
|
|
@@ -927,27 +1024,33 @@ class DaemonClient {
|
|
|
927
1024
|
}
|
|
928
1025
|
async handleConnectionError(error) {
|
|
929
1026
|
logger_1.clientLogger.log(`[Reconnect] Connection error detected: ${error.message}`);
|
|
1027
|
+
// A plugin worker cannot bring a daemon back — `startInBackground` throws
|
|
1028
|
+
// in one — and it is usually hosted by the daemon that just died, so the
|
|
1029
|
+
// 60s reconnect poll almost always ends in the same failure. Make the loss
|
|
1030
|
+
// terminal instead: the in-flight message and every later one fail fast
|
|
1031
|
+
// with a clear error. The cost is that a CLI-hosted worker no longer
|
|
1032
|
+
// survives a daemon restart, and that command fails.
|
|
1033
|
+
if (global.NX_PLUGIN_WORKER) {
|
|
1034
|
+
const pluginWorkerError = daemonProcessException(`Plugin worker lost its daemon connection and cannot reconnect: ${error.message}`);
|
|
1035
|
+
this._pluginWorkerConnectionLost = pluginWorkerError;
|
|
1036
|
+
if (this.currentReject) {
|
|
1037
|
+
this.currentReject(pluginWorkerError);
|
|
1038
|
+
}
|
|
1039
|
+
this.failDaemonReady(pluginWorkerError);
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
930
1042
|
// Create a new ready promise for new requests to wait on
|
|
931
|
-
this._waitForDaemonReady =
|
|
1043
|
+
this._waitForDaemonReady = this.createReadyPromise();
|
|
932
1044
|
// Set status to CONNECTING so new requests will wait for reconnection
|
|
933
1045
|
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
934
|
-
let serverAvailable;
|
|
935
1046
|
try {
|
|
936
|
-
|
|
1047
|
+
const { available } = await this.waitForServerToBeAvailable({
|
|
937
1048
|
ignoreVersionMismatch: false,
|
|
938
|
-
})
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
// New daemon has different version - reject with error so caller can handle
|
|
943
|
-
if (this.currentReject) {
|
|
944
|
-
this.currentReject(err);
|
|
945
|
-
}
|
|
946
|
-
return;
|
|
1049
|
+
});
|
|
1050
|
+
if (!available) {
|
|
1051
|
+
// Out of reconnect attempts, so the error that started this stands.
|
|
1052
|
+
throw error;
|
|
947
1053
|
}
|
|
948
|
-
throw err;
|
|
949
|
-
}
|
|
950
|
-
if (serverAvailable) {
|
|
951
1054
|
logger_1.clientLogger.log(`[Reconnect] Reconnection successful, re-establishing connection`);
|
|
952
1055
|
// Server is back up, establish connection and signal ready
|
|
953
1056
|
this.establishConnection();
|
|
@@ -962,11 +1065,18 @@ class DaemonClient {
|
|
|
962
1065
|
this.sendMessageToDaemon(msg).then(res, rej);
|
|
963
1066
|
}
|
|
964
1067
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1068
|
+
catch (err) {
|
|
1069
|
+
this.failDaemonReady(err);
|
|
1070
|
+
// A new daemon on a different version and an exhausted reconnect are
|
|
1071
|
+
// both answers for the in-flight caller; anything else is unexpected
|
|
1072
|
+
// and propagates.
|
|
1073
|
+
if (err instanceof daemon_socket_messenger_1.VersionMismatchError || err === error) {
|
|
1074
|
+
if (this.currentReject) {
|
|
1075
|
+
this.currentReject(err);
|
|
1076
|
+
}
|
|
1077
|
+
return;
|
|
969
1078
|
}
|
|
1079
|
+
throw err;
|
|
970
1080
|
}
|
|
971
1081
|
}
|
|
972
1082
|
establishConnection() {
|
|
@@ -1026,7 +1136,7 @@ class DaemonClient {
|
|
|
1026
1136
|
: `[Client] Server not available after ${WAIT_FOR_SERVER_CONFIG.maxAttempts} attempts`);
|
|
1027
1137
|
return { available: false, refusal };
|
|
1028
1138
|
}
|
|
1029
|
-
async sendMessageToDaemon(message
|
|
1139
|
+
async sendMessageToDaemon(message) {
|
|
1030
1140
|
// the first message sent to the daemon includes an env prop
|
|
1031
1141
|
// that updates the process.env values on the daemon.
|
|
1032
1142
|
if (!this.envReflectionSent && !global.NX_PLUGIN_WORKER) {
|
|
@@ -1048,7 +1158,7 @@ class DaemonClient {
|
|
|
1048
1158
|
this.currentMessage = message;
|
|
1049
1159
|
this.currentResolve = resolve;
|
|
1050
1160
|
this.currentReject = reject;
|
|
1051
|
-
this.socketMessenger.sendMessage(message
|
|
1161
|
+
this.socketMessenger.sendMessage(message);
|
|
1052
1162
|
}).finally(() => {
|
|
1053
1163
|
clearTimeout(keepAlive);
|
|
1054
1164
|
});
|
|
@@ -6,7 +6,7 @@ export declare class VersionMismatchError extends Error {
|
|
|
6
6
|
export declare class DaemonSocketMessenger {
|
|
7
7
|
private socket;
|
|
8
8
|
constructor(socket: Socket);
|
|
9
|
-
sendMessage<T extends DaemonMessage>(messageToDaemon: T
|
|
9
|
+
sendMessage<T extends DaemonMessage>(messageToDaemon: T): void;
|
|
10
10
|
listen(onData: (message: Buffer) => void, onClose?: () => void, onError?: (err: Error) => void): DaemonSocketMessenger;
|
|
11
11
|
close(): void;
|
|
12
12
|
}
|
|
@@ -18,7 +18,7 @@ class DaemonSocketMessenger {
|
|
|
18
18
|
constructor(socket) {
|
|
19
19
|
this.socket = socket;
|
|
20
20
|
}
|
|
21
|
-
sendMessage(messageToDaemon
|
|
21
|
+
sendMessage(messageToDaemon) {
|
|
22
22
|
if (!this.socket) {
|
|
23
23
|
throw new Error('Socket not initialized.');
|
|
24
24
|
}
|
|
@@ -27,7 +27,7 @@ class DaemonSocketMessenger {
|
|
|
27
27
|
messageToDaemon.workspaceRoot = workspace_root_1.workspaceRoot;
|
|
28
28
|
logger_1.clientLogger.log('[Messenger] Sending message type:', messageToDaemon.type);
|
|
29
29
|
perf_hooks_1.performance.mark('daemon-message-serialization-start-' + messageToDaemon.type);
|
|
30
|
-
const serialized = (0, socket_utils_1.serialize)(messageToDaemon
|
|
30
|
+
const serialized = (0, socket_utils_1.serialize)(messageToDaemon);
|
|
31
31
|
perf_hooks_1.performance.mark('daemon-message-serialization-end-' + messageToDaemon.type);
|
|
32
32
|
perf_hooks_1.performance.measure('daemon-message-serialization-' + messageToDaemon.type, 'daemon-message-serialization-start-' + messageToDaemon.type, 'daemon-message-serialization-end-' + messageToDaemon.type);
|
|
33
33
|
(0, consume_messages_from_socket_1.writeMessage)(this.socket, serialized);
|
|
@@ -50,7 +50,7 @@ function assertOnDaemon(helperName) {
|
|
|
50
50
|
function writeStreamingMessage(socket, payload, description) {
|
|
51
51
|
try {
|
|
52
52
|
logger_1.serverLogger.log('Streaming message to client:', description);
|
|
53
|
-
(0, socket_utils_1.sendMessage)(socket, payload,
|
|
53
|
+
(0, socket_utils_1.sendMessage)(socket, payload, (err) => {
|
|
54
54
|
if (err) {
|
|
55
55
|
console.log(`Streaming message write error (client likely disconnected): ${err.message}`);
|
|
56
56
|
}
|
|
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleProcessInBackground = handleProcessInBackground;
|
|
4
4
|
const logger_1 = require("../logger");
|
|
5
5
|
const installation_directory_1 = require("../../utils/installation-directory");
|
|
6
|
+
const socket_utils_1 = require("../socket-utils");
|
|
7
|
+
const native_js_loader_1 = require("./native-js-loader");
|
|
6
8
|
async function handleProcessInBackground(payload) {
|
|
7
9
|
let fn;
|
|
8
10
|
try {
|
|
9
|
-
fn =
|
|
11
|
+
fn = (0, native_js_loader_1.requireWithNativeJsLoader)(require.resolve(payload.requirePath, {
|
|
10
12
|
paths: (0, installation_directory_1.getNxRequirePaths)(),
|
|
11
13
|
})).default;
|
|
12
14
|
}
|
|
13
15
|
catch (e) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
error: new Error(`Unable to require ${payload.requirePath}`),
|
|
17
|
-
};
|
|
16
|
+
const description = `Unable to require ${payload.requirePath}`;
|
|
17
|
+
return { description, error: toTransportableError(e, description) };
|
|
18
18
|
}
|
|
19
19
|
try {
|
|
20
20
|
const response = await fn(payload.data, logger_1.serverLogger);
|
|
@@ -24,9 +24,21 @@ async function handleProcessInBackground(payload) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
catch (e) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
const description = `Error when processing ${payload.type}.`;
|
|
28
|
+
return { description, error: toTransportableError(e, description) };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function toTransportableError(e, fallbackMessage) {
|
|
32
|
+
if (!(e instanceof Error)) {
|
|
33
|
+
return new Error(fallbackMessage);
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
(0, socket_utils_1.serializeResult)(e, null, null);
|
|
37
|
+
return e;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
const copy = new Error(e.message);
|
|
41
|
+
copy.stack = e.stack;
|
|
42
|
+
return copy;
|
|
31
43
|
}
|
|
32
44
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Socket } from 'net';
|
|
1
2
|
import { AffectedTasksRequest } from '../../project-graph/affected/affected-tasks';
|
|
2
3
|
import type { HandlerResult } from './server';
|
|
3
|
-
export declare function handleSelectAffectedTasks(request: AffectedTasksRequest): Promise<HandlerResult>;
|
|
4
|
+
export declare function handleSelectAffectedTasks(request: AffectedTasksRequest, socket: Socket): Promise<HandlerResult>;
|
|
@@ -3,24 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleSelectAffectedTasks = handleSelectAffectedTasks;
|
|
4
4
|
const configuration_1 = require("../../config/configuration");
|
|
5
5
|
const affected_tasks_1 = require("../../project-graph/affected/affected-tasks");
|
|
6
|
+
const progress_topics_1 = require("../../utils/progress-topics");
|
|
7
|
+
const client_socket_context_1 = require("./client-socket-context");
|
|
6
8
|
const ultracache_configuration_state_1 = require("./ultracache-configuration-state");
|
|
7
9
|
const planning_context_1 = require("./planning-context");
|
|
8
10
|
const project_graph_incremental_recomputation_1 = require("./project-graph-incremental-recomputation");
|
|
9
|
-
async function handleSelectAffectedTasks(request) {
|
|
10
|
-
const { error, projectGraph } = await (0, project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise)();
|
|
11
|
+
async function handleSelectAffectedTasks(request, socket) {
|
|
12
|
+
const { error, projectGraph } = await (0, project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise)(socket);
|
|
11
13
|
if (error) {
|
|
12
14
|
throw error;
|
|
13
15
|
}
|
|
14
16
|
const nxJson = (0, configuration_1.readNxJson)();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
(0, client_socket_context_1.subscribeClientToTopic)(socket, progress_topics_1.ProgressTopics.AffectedTasks);
|
|
18
|
+
try {
|
|
19
|
+
const selection = await (0, affected_tasks_1.selectAffectedTasks)(projectGraph, nxJson, (0, planning_context_1.planningContextFor)(projectGraph, nxJson), request, {
|
|
20
|
+
ultracacheConfigurations: (0, ultracache_configuration_state_1.getUltracacheConfigurationsForVersion)(request.ultracacheConfigurationsVersion),
|
|
21
|
+
});
|
|
22
|
+
const response = {
|
|
23
|
+
projectGraph,
|
|
24
|
+
affectedTaskIds: [...selection.affectedTaskIds],
|
|
25
|
+
taskGraph: selection.taskGraph,
|
|
26
|
+
taskSelection: selection.taskSelection,
|
|
27
|
+
explanation: selection.explanation,
|
|
28
|
+
};
|
|
29
|
+
return { response, description: 'handleSelectAffectedTasks' };
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
(0, client_socket_context_1.unsubscribeClientFromTopic)(socket, progress_topics_1.ProgressTopics.AffectedTasks);
|
|
33
|
+
}
|
|
26
34
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function requireWithNativeJsLoader(path: string): any;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireWithNativeJsLoader = requireWithNativeJsLoader;
|
|
4
|
+
// Captured when the daemon starts, before plugins or sync generators can
|
|
5
|
+
// replace it (e.g. @swc-node/register compiles every .js outside node_modules).
|
|
6
|
+
const nativeJsLoader = require.extensions?.['.js'];
|
|
7
|
+
function requireWithNativeJsLoader(path) {
|
|
8
|
+
// Undefined when a loader hook (e.g. Yarn PnP's) has Node's ESM loader run
|
|
9
|
+
// nx's CommonJS. The require nx gets there never runs .js hooks.
|
|
10
|
+
if (!nativeJsLoader) {
|
|
11
|
+
return require(path);
|
|
12
|
+
}
|
|
13
|
+
const currentJsLoader = require.extensions['.js'];
|
|
14
|
+
require.extensions['.js'] = nativeJsLoader;
|
|
15
|
+
try {
|
|
16
|
+
return require(path);
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
require.extensions['.js'] = currentJsLoader;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -36,7 +36,6 @@ const collectedUpdatedFiles = new Map();
|
|
|
36
36
|
const collectedDeletedFiles = new Map();
|
|
37
37
|
const projectGraphRecomputationListeners = new Set();
|
|
38
38
|
let storedWorkspaceConfigHash;
|
|
39
|
-
let knownExternalNodes = {};
|
|
40
39
|
let fileChangeCounter = 0;
|
|
41
40
|
let recomputationGeneration = 0;
|
|
42
41
|
// The graph the settled cached promise serves, with the generation its
|
|
@@ -341,7 +340,7 @@ function computeWorkspaceConfigHash(projectsConfigurations) {
|
|
|
341
340
|
.map(([projectName, projectConfig]) => `${projectName}:${JSON.stringify(projectConfig)}`);
|
|
342
341
|
return (0, file_hasher_1.hashArray)(projectConfigurationStrings);
|
|
343
342
|
}
|
|
344
|
-
async function processCollectedUpdatedAndDeletedFiles({ projects,
|
|
343
|
+
async function processCollectedUpdatedAndDeletedFiles({ projects, projectRootMap }, updatedFileHashes, deletedFiles) {
|
|
345
344
|
try {
|
|
346
345
|
const configHash = computeWorkspaceConfigHash(projects);
|
|
347
346
|
// Config changed → can't incrementally update; refetch the file map
|
|
@@ -350,7 +349,7 @@ async function processCollectedUpdatedAndDeletedFiles({ projects, externalNodes,
|
|
|
350
349
|
// can't clobber a faster newer one's already-committed state.
|
|
351
350
|
if (configHash !== storedWorkspaceConfigHash) {
|
|
352
351
|
const fresh = await (0, retrieve_workspace_files_1.retrieveWorkspaceFiles)(workspace_root_1.workspaceRoot, projectRootMap);
|
|
353
|
-
return { fileMap: fresh, configHash
|
|
352
|
+
return { fileMap: fresh, configHash };
|
|
354
353
|
}
|
|
355
354
|
// Config unchanged → patch the existing file map in place.
|
|
356
355
|
if (exports.fileMapWithFiles) {
|
|
@@ -477,9 +476,6 @@ async function processFilesAndCreateAndSerializeProjectGraph(separatedPlugins) {
|
|
|
477
476
|
// can't clobber a newer compute's write.
|
|
478
477
|
exports.fileMapWithFiles = fileMapUpdate.fileMap;
|
|
479
478
|
storedWorkspaceConfigHash = fileMapUpdate.configHash;
|
|
480
|
-
if (fileMapUpdate.knownExternalNodes) {
|
|
481
|
-
knownExternalNodes = fileMapUpdate.knownExternalNodes;
|
|
482
|
-
}
|
|
483
479
|
// Drain only after committing — a stale compute that returns at the
|
|
484
480
|
// staleness check above must leave its snapshot in `collected*` so the
|
|
485
481
|
// newer compute still sees those files. Removing them earlier would
|
|
@@ -604,12 +600,12 @@ function copyFileMap(m) {
|
|
|
604
600
|
}
|
|
605
601
|
return c;
|
|
606
602
|
}
|
|
607
|
-
async function createAndSerializeProjectGraph({ projects, sourceMaps, }) {
|
|
603
|
+
async function createAndSerializeProjectGraph({ projects, externalNodes, sourceMaps, }) {
|
|
608
604
|
try {
|
|
609
605
|
perf_hooks_1.performance.mark('create-project-graph-start');
|
|
610
606
|
const fileMap = copyFileMap(exports.fileMapWithFiles.fileMap);
|
|
611
607
|
const rustReferences = exports.fileMapWithFiles.rustReferences;
|
|
612
|
-
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects,
|
|
608
|
+
const { projectGraph, projectFileMapCache } = await (0, build_project_graph_1.buildProjectGraphUsingProjectFileMap)(projects, externalNodes, fileMap, rustReferences, exports.currentProjectFileMapCache || (0, nx_deps_cache_1.readFileMapCache)(), await (0, get_plugins_1.getPlugins)((0, nx_json_1.readNxJson)(workspace_root_1.workspaceRoot)), sourceMaps);
|
|
613
609
|
exports.currentProjectFileMapCache = projectFileMapCache;
|
|
614
610
|
exports.currentProjectGraph = projectGraph;
|
|
615
611
|
exports.currentSourceMaps = sourceMaps;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Server, Socket } from 'net';
|
|
2
2
|
import '../../utils/perf-logging';
|
|
3
|
+
import { respondWithErrorAndExit } from './shutdown-utils';
|
|
3
4
|
export type HandlerResult = {
|
|
4
5
|
description: string;
|
|
5
6
|
error?: any;
|
|
@@ -7,5 +8,5 @@ export type HandlerResult = {
|
|
|
7
8
|
};
|
|
8
9
|
export declare const openSockets: Set<Socket>;
|
|
9
10
|
export declare function handleMessage(socket: Socket, data: Buffer): Promise<void>;
|
|
10
|
-
export declare function handleResult(socket: Socket, type: string, hrFn: () => Promise<HandlerResult>, mode: 'json' | 'v8'): Promise<void>;
|
|
11
|
+
export declare function handleResult(socket: Socket, type: string, hrFn: () => Promise<HandlerResult>, mode: 'json' | 'v8', respondToError?: typeof respondWithErrorAndExit): Promise<void>;
|
|
11
12
|
export declare function startServer(): Promise<Server>;
|