nx 23.3.0 → 24.0.0-beta.1
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/nx-cloud-internals.d.ts +1 -0
- package/dist/nx-cloud-internals.js +7 -1
- package/dist/src/adapter/ngcli-adapter.js +1 -0
- package/dist/src/command-line/configure-ai-agents/configure-ai-agents.js +0 -12
- package/dist/src/command-line/graph/graph.js +3 -5
- package/dist/src/command-line/init/command-object.js +0 -12
- 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/master/spawn-master.js +76 -15
- package/dist/src/command-line/migrate/execute-migration.d.ts +2 -2
- package/dist/src/command-line/migrate/execute-migration.js +18 -10
- package/dist/src/command-line/migrate/migrate-commits.d.ts +4 -1
- package/dist/src/command-line/migrate/migrate-commits.js +10 -3
- package/dist/src/command-line/migrate/migrate.js +43 -6
- package/dist/src/command-line/migrate/run/agent-output.d.ts +1 -0
- package/dist/src/command-line/migrate/run/agent-output.js +5 -0
- package/dist/src/command-line/migrate/run/broker.d.ts +14 -5
- package/dist/src/command-line/migrate/run/broker.js +68 -20
- package/dist/src/command-line/migrate/run/index.d.ts +4 -3
- package/dist/src/command-line/migrate/run/index.js +8 -1
- package/dist/src/command-line/migrate/run/orchestrator.js +72 -13
- package/dist/src/command-line/migrate/run/runbook.js +19 -0
- package/dist/src/command-line/migrate/run/state-machine.js +4 -1
- package/dist/src/command-line/migrate/run/util.d.ts +3 -0
- package/dist/src/command-line/migrate/run/util.js +7 -1
- package/dist/src/command-line/nx-cloud/connect/connect-to-nx-cloud.js +17 -12
- 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/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/show/show-target/info.js +1 -1
- 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/config/misc-interfaces.d.ts +12 -0
- package/dist/src/config/task-graph.d.ts +1 -1
- package/dist/src/config/workspace-json-project-json.d.ts +65 -0
- package/dist/src/core/graph/main.js +1 -1
- package/dist/src/daemon/client/client.d.ts +9 -0
- package/dist/src/daemon/client/client.js +89 -37
- package/dist/src/daemon/server/shutdown-utils.js +0 -3
- package/dist/src/daemon/socket-utils.d.ts +9 -4
- package/dist/src/daemon/socket-utils.js +12 -49
- 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 +1 -1
- package/dist/src/devkit-internals.d.ts +1 -1
- package/dist/src/devkit-internals.js +1 -0
- package/dist/src/hasher/check-task-files.js +4 -4
- 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/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 +145 -0
- package/dist/src/native/index.d.ts +180 -12
- package/dist/src/native/native-bindings.js +8 -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 +7 -0
- package/dist/src/nx-cloud/update-manager.js +237 -50
- package/dist/src/project-graph/affected/affected-tasks.js +1 -0
- package/dist/src/project-graph/plugins/isolation/isolated-plugin.js +7 -0
- package/dist/src/tasks-runner/create-task-graph.d.ts +8 -7
- package/dist/src/tasks-runner/create-task-graph.js +47 -26
- package/dist/src/tasks-runner/init-tasks-runner.js +13 -0
- 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/readiness/probes.d.ts +9 -0
- package/dist/src/tasks-runner/readiness/probes.js +62 -0
- package/dist/src/tasks-runner/readiness/ready-when.d.ts +38 -0
- package/dist/src/tasks-runner/readiness/ready-when.js +190 -0
- package/dist/src/tasks-runner/run-command.js +5 -4
- package/dist/src/tasks-runner/running-tasks/node-child-process.js +5 -4
- package/dist/src/tasks-runner/task-env.d.ts +10 -0
- package/dist/src/tasks-runner/task-env.js +26 -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 +37 -8
- package/dist/src/tasks-runner/task-orchestrator.js +460 -76
- package/dist/src/tasks-runner/tasks-schedule.d.ts +18 -1
- package/dist/src/tasks-runner/tasks-schedule.js +64 -6
- package/dist/src/tasks-runner/utils.d.ts +20 -5
- package/dist/src/tasks-runner/utils.js +70 -35
- package/dist/src/ultracache/overrides.js +4 -0
- package/dist/src/utils/child-process.js +1 -0
- package/dist/src/utils/git-utils.d.ts +6 -1
- package/dist/src/utils/git-utils.js +26 -5
- 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/perf-hooks.d.ts +1 -0
- package/dist/src/utils/plugins/core-plugins.js +1 -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 +7 -0
- package/package.json +11 -20
- package/readme-template.md +3 -3
- package/schemas/nx-schema.json +70 -0
- package/schemas/project-schema.json +67 -0
- 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
|
@@ -23,6 +23,11 @@ export type ChangedFile = {
|
|
|
23
23
|
path: string;
|
|
24
24
|
type: 'create' | 'update' | 'delete';
|
|
25
25
|
};
|
|
26
|
+
export declare enum DaemonStatus {
|
|
27
|
+
CONNECTING = 0,
|
|
28
|
+
DISCONNECTED = 1,
|
|
29
|
+
CONNECTED = 2
|
|
30
|
+
}
|
|
26
31
|
/**
|
|
27
32
|
* The daemon's workspace watcher died. Nothing it serves will see file changes
|
|
28
33
|
* again, so a watching client has to restart rather than keep waiting.
|
|
@@ -43,6 +48,8 @@ export declare class DaemonClient {
|
|
|
43
48
|
private _daemonStatus;
|
|
44
49
|
private _waitForDaemonReady;
|
|
45
50
|
private _daemonReady;
|
|
51
|
+
private _daemonReadyFailed;
|
|
52
|
+
private _pluginWorkerConnectionLost;
|
|
46
53
|
private fileWatcherMessenger;
|
|
47
54
|
private fileWatcherReconnecting;
|
|
48
55
|
private fileWatcherFramingFailures;
|
|
@@ -54,6 +61,8 @@ export declare class DaemonClient {
|
|
|
54
61
|
private projectGraphListenerCallbacks;
|
|
55
62
|
enabled(): boolean;
|
|
56
63
|
reset(): void;
|
|
64
|
+
private createReadyPromise;
|
|
65
|
+
private failDaemonReady;
|
|
57
66
|
private getSocketPath;
|
|
58
67
|
requestShutdown(): Promise<void>;
|
|
59
68
|
getProjectGraphAndSourceMaps(): Promise<{
|
|
@@ -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,6 +95,9 @@ 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;
|
|
100
103
|
this.fileWatcherCallbacks = new Map();
|
|
@@ -166,7 +169,26 @@ class DaemonClient {
|
|
|
166
169
|
this.projectGraphListenerMessenger?.close();
|
|
167
170
|
this.projectGraphListenerMessenger = undefined;
|
|
168
171
|
this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
169
|
-
this.
|
|
172
|
+
this._pluginWorkerConnectionLost = null;
|
|
173
|
+
this._waitForDaemonReady = this.createReadyPromise();
|
|
174
|
+
}
|
|
175
|
+
createReadyPromise() {
|
|
176
|
+
const promise = new Promise((resolve, reject) => {
|
|
177
|
+
this._daemonReady = resolve;
|
|
178
|
+
this._daemonReadyFailed = reject;
|
|
179
|
+
});
|
|
180
|
+
// Callers don't always await — swallow the unhandled-rejection warning
|
|
181
|
+
// so a rejected ready promise that no one observes doesn't crash the
|
|
182
|
+
// process. Real awaiters still see the rejection.
|
|
183
|
+
promise.catch(() => { });
|
|
184
|
+
return promise;
|
|
185
|
+
}
|
|
186
|
+
// Move out of CONNECTING and surface an error to every caller parked on
|
|
187
|
+
// `_waitForDaemonReady`. Without this, a failure while CONNECTING leaves
|
|
188
|
+
// concurrent callers waiting on a promise that will never settle.
|
|
189
|
+
failDaemonReady(err) {
|
|
190
|
+
this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
191
|
+
this._daemonReadyFailed?.(err);
|
|
170
192
|
}
|
|
171
193
|
getSocketPath() {
|
|
172
194
|
const daemonProcessJson = (0, cache_1.readDaemonProcessJsonCache)();
|
|
@@ -821,33 +843,50 @@ class DaemonClient {
|
|
|
821
843
|
return (await this.probeServer()).available;
|
|
822
844
|
}
|
|
823
845
|
async startDaemonIfNecessary() {
|
|
846
|
+
if (this._pluginWorkerConnectionLost) {
|
|
847
|
+
throw this._pluginWorkerConnectionLost;
|
|
848
|
+
}
|
|
824
849
|
if (this._daemonStatus == DaemonStatus.CONNECTED) {
|
|
825
850
|
return;
|
|
826
851
|
}
|
|
827
852
|
// Ensure daemon is running and socket path is available
|
|
828
853
|
if (this._daemonStatus == DaemonStatus.DISCONNECTED) {
|
|
854
|
+
// Create a fresh ready promise for any concurrent caller that hits
|
|
855
|
+
// the CONNECTING branch below before this attempt resolves.
|
|
856
|
+
this._waitForDaemonReady = this.createReadyPromise();
|
|
829
857
|
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
830
858
|
let daemonPid = null;
|
|
831
|
-
let probe;
|
|
832
859
|
try {
|
|
833
|
-
probe
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
860
|
+
let probe;
|
|
861
|
+
try {
|
|
862
|
+
probe = await this.probeServer();
|
|
863
|
+
}
|
|
864
|
+
catch (err) {
|
|
865
|
+
// Version mismatch - treat as server not available, start new one
|
|
866
|
+
if (err instanceof daemon_socket_messenger_1.VersionMismatchError) {
|
|
867
|
+
probe = { available: false };
|
|
868
|
+
}
|
|
869
|
+
else {
|
|
870
|
+
throw err;
|
|
871
|
+
}
|
|
839
872
|
}
|
|
840
|
-
|
|
841
|
-
|
|
873
|
+
if (!probe.available) {
|
|
874
|
+
// Carried as a value so no other caller's probe can substitute for it.
|
|
875
|
+
daemonPid = await this.startInBackground(probe.refusal);
|
|
842
876
|
}
|
|
877
|
+
this.setUpConnection();
|
|
878
|
+
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
879
|
+
this._daemonReady();
|
|
843
880
|
}
|
|
844
|
-
|
|
845
|
-
//
|
|
846
|
-
|
|
881
|
+
catch (err) {
|
|
882
|
+
// Reset to DISCONNECTED and reject the ready promise so every
|
|
883
|
+
// concurrent caller parked on the CONNECTING branch gets the
|
|
884
|
+
// error instead of hanging forever.
|
|
885
|
+
this.failDaemonReady(err);
|
|
886
|
+
throw err;
|
|
847
887
|
}
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
this._daemonReady();
|
|
888
|
+
// Outside the try: the connection is established by now, and a throw
|
|
889
|
+
// from here must not undo it.
|
|
851
890
|
daemonPid ??= (0, cache_1.getDaemonProcessIdSync)();
|
|
852
891
|
// Fire-and-forget - don't block daemon connection by waiting for metrics registration
|
|
853
892
|
this.registerDaemonProcessWithMetricsService(daemonPid);
|
|
@@ -927,27 +966,33 @@ class DaemonClient {
|
|
|
927
966
|
}
|
|
928
967
|
async handleConnectionError(error) {
|
|
929
968
|
logger_1.clientLogger.log(`[Reconnect] Connection error detected: ${error.message}`);
|
|
969
|
+
// A plugin worker cannot bring a daemon back — `startInBackground` throws
|
|
970
|
+
// in one — and it is usually hosted by the daemon that just died, so the
|
|
971
|
+
// 60s reconnect poll almost always ends in the same failure. Make the loss
|
|
972
|
+
// terminal instead: the in-flight message and every later one fail fast
|
|
973
|
+
// with a clear error. The cost is that a CLI-hosted worker no longer
|
|
974
|
+
// survives a daemon restart, and that command fails.
|
|
975
|
+
if (global.NX_PLUGIN_WORKER) {
|
|
976
|
+
const pluginWorkerError = daemonProcessException(`Plugin worker lost its daemon connection and cannot reconnect: ${error.message}`);
|
|
977
|
+
this._pluginWorkerConnectionLost = pluginWorkerError;
|
|
978
|
+
if (this.currentReject) {
|
|
979
|
+
this.currentReject(pluginWorkerError);
|
|
980
|
+
}
|
|
981
|
+
this.failDaemonReady(pluginWorkerError);
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
930
984
|
// Create a new ready promise for new requests to wait on
|
|
931
|
-
this._waitForDaemonReady =
|
|
985
|
+
this._waitForDaemonReady = this.createReadyPromise();
|
|
932
986
|
// Set status to CONNECTING so new requests will wait for reconnection
|
|
933
987
|
this._daemonStatus = DaemonStatus.CONNECTING;
|
|
934
|
-
let serverAvailable;
|
|
935
988
|
try {
|
|
936
|
-
|
|
989
|
+
const { available } = await this.waitForServerToBeAvailable({
|
|
937
990
|
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;
|
|
991
|
+
});
|
|
992
|
+
if (!available) {
|
|
993
|
+
// Out of reconnect attempts, so the error that started this stands.
|
|
994
|
+
throw error;
|
|
947
995
|
}
|
|
948
|
-
throw err;
|
|
949
|
-
}
|
|
950
|
-
if (serverAvailable) {
|
|
951
996
|
logger_1.clientLogger.log(`[Reconnect] Reconnection successful, re-establishing connection`);
|
|
952
997
|
// Server is back up, establish connection and signal ready
|
|
953
998
|
this.establishConnection();
|
|
@@ -962,11 +1007,18 @@ class DaemonClient {
|
|
|
962
1007
|
this.sendMessageToDaemon(msg).then(res, rej);
|
|
963
1008
|
}
|
|
964
1009
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1010
|
+
catch (err) {
|
|
1011
|
+
this.failDaemonReady(err);
|
|
1012
|
+
// A new daemon on a different version and an exhausted reconnect are
|
|
1013
|
+
// both answers for the in-flight caller; anything else is unexpected
|
|
1014
|
+
// and propagates.
|
|
1015
|
+
if (err instanceof daemon_socket_messenger_1.VersionMismatchError || err === error) {
|
|
1016
|
+
if (this.currentReject) {
|
|
1017
|
+
this.currentReject(err);
|
|
1018
|
+
}
|
|
1019
|
+
return;
|
|
969
1020
|
}
|
|
1021
|
+
throw err;
|
|
970
1022
|
}
|
|
971
1023
|
}
|
|
972
1024
|
establishConnection() {
|
|
@@ -11,7 +11,6 @@ const workspace_root_1 = require("../../utils/workspace-root");
|
|
|
11
11
|
const logger_1 = require("../logger");
|
|
12
12
|
const socket_utils_1 = require("../socket-utils");
|
|
13
13
|
const cache_1 = require("../cache");
|
|
14
|
-
const workspace_context_1 = require("../../utils/workspace-context");
|
|
15
14
|
const error_types_1 = require("../../project-graph/error-types");
|
|
16
15
|
const get_plugins_1 = require("../../project-graph/plugins/get-plugins");
|
|
17
16
|
const consume_messages_from_socket_1 = require("../../utils/consume-messages-from-socket");
|
|
@@ -78,8 +77,6 @@ async function performShutdown(server, reason, sockets) {
|
|
|
78
77
|
socket.destroy();
|
|
79
78
|
}
|
|
80
79
|
});
|
|
81
|
-
(0, workspace_context_1.stopWatchingWorkspaceContext)();
|
|
82
|
-
logger_1.serverLogger.watcherLog(`Stopping the watch for ${workspace_root_1.workspaceRoot}`);
|
|
83
80
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
|
84
81
|
(0, get_plugins_1.cleanupPlugins)();
|
|
85
82
|
// Clean up shared latest Nx installation
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import type { Socket } from 'net';
|
|
2
2
|
export declare const isWindows: boolean;
|
|
3
3
|
/**
|
|
4
|
-
* For IPC with the daemon server we use unix sockets or windows named pipes,
|
|
4
|
+
* For IPC with the daemon server we use unix sockets or windows named pipes,
|
|
5
|
+
* depending on the user's operating system.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* The paths themselves — the directory, the file name, the named-pipe form, and
|
|
8
|
+
* the length budget — are all decided in `native/utils/socket_path.rs`, so that
|
|
9
|
+
* Nx and Nx Console cannot disagree about where a socket lives.
|
|
10
|
+
*
|
|
11
|
+
* See https://nodejs.org/dist/latest-v14.x/docs/api/net.html#net_identifying_paths_for_ipc_connections
|
|
12
|
+
* for a full breakdown of OS differences between Unix domain sockets and named
|
|
13
|
+
* pipes.
|
|
8
14
|
*/
|
|
9
15
|
export declare const getFullOsSocketPath: () => string;
|
|
10
16
|
export declare const getForkedProcessOsSocketPath: (id: string) => string;
|
|
11
17
|
export declare const getPluginOsSocketPath: (id: string) => string;
|
|
12
|
-
export declare function getPluginSocketFileName(id: string): string;
|
|
13
18
|
export declare function killSocketOrPath(): void;
|
|
14
19
|
export declare function serializeResult(error: Error | null, serializedProjectGraph: string | null, serializedSourceMaps: string | null): string | null;
|
|
15
20
|
/**
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPluginOsSocketPath = exports.getForkedProcessOsSocketPath = exports.getFullOsSocketPath = exports.isWindows = void 0;
|
|
4
|
-
exports.getPluginSocketFileName = getPluginSocketFileName;
|
|
5
4
|
exports.killSocketOrPath = killSocketOrPath;
|
|
6
5
|
exports.serializeResult = serializeResult;
|
|
7
6
|
exports.serializeWithFallback = serializeWithFallback;
|
|
@@ -9,7 +8,6 @@ exports.serialize = serialize;
|
|
|
9
8
|
exports.sendMessage = sendMessage;
|
|
10
9
|
const fs_1 = require("fs");
|
|
11
10
|
const os_1 = require("os");
|
|
12
|
-
const path_1 = require("path");
|
|
13
11
|
const tmp_dir_1 = require("./tmp-dir");
|
|
14
12
|
const serializable_error_1 = require("../utils/serializable-error");
|
|
15
13
|
const is_v8_serializer_enabled_1 = require("./is-v8-serializer-enabled");
|
|
@@ -17,58 +15,23 @@ const v8_1 = require("v8");
|
|
|
17
15
|
const consume_messages_from_socket_1 = require("../utils/consume-messages-from-socket");
|
|
18
16
|
exports.isWindows = (0, os_1.platform)() === 'win32';
|
|
19
17
|
/**
|
|
20
|
-
* For IPC with the daemon server we use unix sockets or windows named pipes,
|
|
18
|
+
* For IPC with the daemon server we use unix sockets or windows named pipes,
|
|
19
|
+
* depending on the user's operating system.
|
|
21
20
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
21
|
+
* The paths themselves — the directory, the file name, the named-pipe form, and
|
|
22
|
+
* the length budget — are all decided in `native/utils/socket_path.rs`, so that
|
|
23
|
+
* Nx and Nx Console cannot disagree about where a socket lives.
|
|
24
|
+
*
|
|
25
|
+
* See https://nodejs.org/dist/latest-v14.x/docs/api/net.html#net_identifying_paths_for_ipc_connections
|
|
26
|
+
* for a full breakdown of OS differences between Unix domain sockets and named
|
|
27
|
+
* pipes.
|
|
24
28
|
*/
|
|
25
|
-
const getFullOsSocketPath = () =>
|
|
26
|
-
const path = (0, path_1.resolve)((0, tmp_dir_1.getDaemonSocketDir)());
|
|
27
|
-
assertValidSocketPath(path);
|
|
28
|
-
return exports.isWindows ? '\\\\.\\pipe\\nx\\' + path : path;
|
|
29
|
-
};
|
|
29
|
+
const getFullOsSocketPath = () => (0, tmp_dir_1.getDaemonSocketPath)();
|
|
30
30
|
exports.getFullOsSocketPath = getFullOsSocketPath;
|
|
31
|
-
const getForkedProcessOsSocketPath = (id) =>
|
|
32
|
-
let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getSocketDir)(), 'fp' + id + '.sock'));
|
|
33
|
-
assertValidSocketPath(path);
|
|
34
|
-
return exports.isWindows ? '\\\\.\\pipe\\nx\\' + path : path;
|
|
35
|
-
};
|
|
31
|
+
const getForkedProcessOsSocketPath = (id) => (0, tmp_dir_1.getForkedProcessSocketPath)(id);
|
|
36
32
|
exports.getForkedProcessOsSocketPath = getForkedProcessOsSocketPath;
|
|
37
|
-
const getPluginOsSocketPath = (id) =>
|
|
38
|
-
let path = (0, path_1.resolve)((0, path_1.join)((0, tmp_dir_1.getPluginSocketDir)(), getPluginSocketFileName(id)));
|
|
39
|
-
assertValidSocketPath(path);
|
|
40
|
-
return exports.isWindows ? '\\\\.\\pipe\\nx\\' + path : path;
|
|
41
|
-
};
|
|
33
|
+
const getPluginOsSocketPath = (id) => (0, tmp_dir_1.getPluginSocketPath)(id);
|
|
42
34
|
exports.getPluginOsSocketPath = getPluginOsSocketPath;
|
|
43
|
-
function getPluginSocketFileName(id) {
|
|
44
|
-
return `p${id}.sock`;
|
|
45
|
-
}
|
|
46
|
-
function assertValidSocketPath(path) {
|
|
47
|
-
if (path.length > 95) {
|
|
48
|
-
const fallbackCause = (0, tmp_dir_1.getSocketDirFallbackCause)();
|
|
49
|
-
const refusedConfiguredSocketDir = (0, tmp_dir_1.getRefusedConfiguredSocketDir)();
|
|
50
|
-
throw new Error([
|
|
51
|
-
'Attempted to open socket that exceeds the maximum socket length.',
|
|
52
|
-
...(fallbackCause === undefined
|
|
53
|
-
? []
|
|
54
|
-
: [
|
|
55
|
-
`Nx fell back to ${(0, path_1.dirname)(path)} because the default socket directory could not be used.`,
|
|
56
|
-
'Run the command with --verbose to see why the default directory was rejected.',
|
|
57
|
-
]),
|
|
58
|
-
'',
|
|
59
|
-
...(refusedConfiguredSocketDir === undefined
|
|
60
|
-
? [
|
|
61
|
-
`Set NX_SOCKET_DIR to a shorter path (e.g. ${exports.isWindows ? '%TMP%/nx-tmp' : '/tmp/nx-tmp'}) to avoid this issue.`,
|
|
62
|
-
]
|
|
63
|
-
: [
|
|
64
|
-
// Saying "set a shorter path" here would be advice they already
|
|
65
|
-
// followed: they set one, and it was refused for another reason.
|
|
66
|
-
`The directory set in NX_SOCKET_DIR (${refusedConfiguredSocketDir}) could not be used — see the warning above — so Nx fell back to a longer path.`,
|
|
67
|
-
'Point NX_SOCKET_DIR at a short directory your user owns.',
|
|
68
|
-
]),
|
|
69
|
-
].join('\n'), fallbackCause === undefined ? undefined : { cause: fallbackCause });
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
35
|
function killSocketOrPath() {
|
|
73
36
|
try {
|
|
74
37
|
(0, fs_1.unlinkSync)((0, exports.getFullOsSocketPath)());
|
|
@@ -24,7 +24,6 @@ export declare class InvalidSocketDirConfigured extends Error {
|
|
|
24
24
|
}
|
|
25
25
|
export declare const DAEMON_DIR_FOR_CURRENT_WORKSPACE: string;
|
|
26
26
|
export declare const DAEMON_OUTPUT_LOG_FILE: string;
|
|
27
|
-
export declare const getDaemonSocketDir: () => string;
|
|
28
27
|
export declare function writeDaemonLogs(error?: string): string;
|
|
29
28
|
export declare function markDaemonAsDisabled(reason: string): void;
|
|
30
29
|
/**
|
|
@@ -38,25 +37,31 @@ export declare function markDaemonAsDisabled(reason: string): void;
|
|
|
38
37
|
*/
|
|
39
38
|
export declare function disableDaemonForThisProcess(reason: string): void;
|
|
40
39
|
export declare function isDaemonDisabled(): boolean;
|
|
41
|
-
export declare function getSocketDir(): string;
|
|
42
|
-
/**
|
|
43
|
-
* Plugin worker sockets get their own workspace-scoped directory rather than
|
|
44
|
-
* sitting in the shared system temp dir, which cannot be locked down.
|
|
45
|
-
*/
|
|
46
|
-
export declare function getPluginSocketDir(): string;
|
|
47
40
|
/**
|
|
48
41
|
* Exported for tests: both fallback warnings fire once per process, so a suite
|
|
49
42
|
* that stages either fallback more than once has to clear the latches between
|
|
50
43
|
* cases.
|
|
51
44
|
*/
|
|
52
45
|
export declare function resetSocketDirWarningsForTesting(): void;
|
|
53
|
-
|
|
46
|
+
/** The daemon's own socket. */
|
|
47
|
+
export declare function getDaemonSocketPath(): string;
|
|
48
|
+
/** A forked task process's socket, in the daemon's per-run directory. */
|
|
49
|
+
export declare function getForkedProcessSocketPath(id: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Plugin worker sockets get their own workspace-scoped directory rather than
|
|
52
|
+
* sitting in the shared system temp dir, which cannot be locked down.
|
|
53
|
+
*/
|
|
54
|
+
export declare function getPluginSocketPath(id: string): string;
|
|
54
55
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
56
|
+
* Where the Nx Console socket lives, for whoever binds or connects to it.
|
|
57
|
+
*
|
|
58
|
+
* Nx Console is the server here and Nx the client, so the extension listens
|
|
59
|
+
* where this says and Nx dials it.
|
|
60
|
+
*
|
|
61
|
+
* @param workspaceRootOverride the workspace to resolve for, when the caller is
|
|
62
|
+
* not itself running inside it (Nx Console runs in the editor's extension host)
|
|
63
|
+
* @param env the environment to read `NX_SOCKET_DIR` from, for callers that
|
|
64
|
+
* load a workspace `.env` into a copy rather than into `process.env`
|
|
60
65
|
*/
|
|
61
|
-
export declare function
|
|
66
|
+
export declare function getNxConsoleSocketPath(workspaceRootOverride?: string, env?: Record<string, string>): string;
|
|
62
67
|
export declare function removeSocketDir(): void;
|