@smoothbricks/nx-plugin 0.7.18 → 0.7.19
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 +160 -99
- package/dist/.build-inputs.json +35 -29
- package/dist/built-output-packages.js +1 -1
- package/dist/cargo-closure-input.js +1 -1
- package/dist/cargo-source-hash.d.ts +3 -21
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +4 -91
- package/dist/cargo-toolchain-paths.d.ts +2 -2
- package/dist/cargo-toolchain-paths.js +2 -2
- package/dist/cargo-workspace.d.ts.map +1 -1
- package/dist/cargo-workspace.js +2 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts +3 -1
- package/dist/executors/bounded-exec/admission-queue.d.ts.map +1 -1
- package/dist/executors/bounded-exec/admission-queue.js +9 -10
- package/dist/executors/bounded-exec/awake-clock.d.ts +5 -0
- package/dist/executors/bounded-exec/awake-clock.d.ts.map +1 -0
- package/dist/executors/bounded-exec/awake-clock.js +22 -0
- package/dist/executors/bounded-exec/bounds.d.ts +7 -5
- package/dist/executors/bounded-exec/bounds.d.ts.map +1 -1
- package/dist/executors/bounded-exec/bounds.js +14 -11
- package/dist/executors/bounded-exec/case-gate.d.ts +114 -0
- package/dist/executors/bounded-exec/case-gate.d.ts.map +1 -0
- package/dist/executors/bounded-exec/case-gate.js +342 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts +1 -0
- package/dist/executors/bounded-exec/cpu-pool-thread.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool-thread.js +2 -2
- package/dist/executors/bounded-exec/cpu-pool.d.ts +28 -1
- package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-pool.js +102 -16
- package/dist/executors/bounded-exec/endpoint-life.d.ts +146 -0
- package/dist/executors/bounded-exec/endpoint-life.d.ts.map +1 -0
- package/dist/executors/bounded-exec/endpoint-life.js +228 -0
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +207 -69
- package/dist/executors/bounded-exec/gateway-lease.d.ts +1 -1
- package/dist/executors/bounded-exec/gateway-lease.d.ts.map +1 -1
- package/dist/executors/bounded-exec/gateway-lease.js +8 -1
- package/dist/executors/bounded-exec/go-run-summary.d.ts +51 -0
- package/dist/executors/bounded-exec/go-run-summary.d.ts.map +1 -0
- package/dist/executors/bounded-exec/go-run-summary.js +98 -0
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts +3 -3
- package/dist/executors/bounded-exec/hang-diagnostics.d.ts.map +1 -1
- package/dist/executors/bounded-exec/hang-diagnostics.js +66 -48
- package/dist/executors/bounded-exec/lease-wait.d.ts +1 -0
- package/dist/executors/bounded-exec/lease-wait.d.ts.map +1 -1
- package/dist/executors/bounded-exec/lease-wait.js +1 -0
- package/dist/executors/bounded-exec/mbx-pool.d.ts +28 -7
- package/dist/executors/bounded-exec/mbx-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-pool.js +30 -9
- package/dist/executors/bounded-exec/mbx-reservations.d.ts +8 -5
- package/dist/executors/bounded-exec/mbx-reservations.d.ts.map +1 -1
- package/dist/executors/bounded-exec/mbx-reservations.js +187 -283
- package/dist/executors/bounded-exec/parent-grant.d.ts +2 -0
- package/dist/executors/bounded-exec/parent-grant.d.ts.map +1 -1
- package/dist/executors/bounded-exec/parent-grant.js +1 -0
- package/dist/executors/bounded-exec/pool-admission.d.ts +29 -3
- package/dist/executors/bounded-exec/pool-admission.d.ts.map +1 -1
- package/dist/executors/bounded-exec/pool-admission.js +47 -1
- package/dist/executors/bounded-exec/progress.d.ts +3 -0
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +31 -1
- package/dist/executors/bounded-exec/reservation-connection.d.ts +90 -0
- package/dist/executors/bounded-exec/reservation-connection.d.ts.map +1 -0
- package/dist/executors/bounded-exec/reservation-connection.js +248 -0
- package/dist/executors/bounded-exec/run-cpu-pool.d.ts.map +1 -1
- package/dist/executors/bounded-exec/run-cpu-pool.js +3 -0
- package/dist/executors/bounded-exec/runner-sizing.d.ts +9 -5
- package/dist/executors/bounded-exec/runner-sizing.d.ts.map +1 -1
- package/dist/executors/bounded-exec/runner-sizing.js +13 -9
- package/dist/executors/bounded-exec/schema.d.ts +2 -2
- package/dist/executors/bounded-exec/suite-minimum.d.ts +21 -0
- package/dist/executors/bounded-exec/suite-minimum.d.ts.map +1 -0
- package/dist/executors/bounded-exec/suite-minimum.js +85 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts +2 -0
- package/dist/executors/bounded-exec/test-result-writer.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-result-writer.js +1 -0
- package/dist/executors/bounded-exec/test-results.d.ts +5 -0
- package/dist/executors/bounded-exec/test-results.d.ts.map +1 -1
- package/dist/executors/bounded-exec/test-results.js +2 -2
- package/dist/executors/bounded-exec/verdict.d.ts +26 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +26 -5
- package/dist/executors/cargo-zigbuild/executor.d.ts +10 -8
- package/dist/executors/cargo-zigbuild/executor.d.ts.map +1 -1
- package/dist/executors/cargo-zigbuild/executor.js +32 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -73
- package/dist/managed-files/ci-workflow.d.ts +4 -1
- package/dist/managed-files/ci-workflow.d.ts.map +1 -1
- package/dist/managed-files/ci-workflow.js +9 -14
- package/dist/managed-files/files.d.ts +3 -3
- package/dist/managed-files/files.js +3 -3
- package/dist/task-results.js +2 -1
- package/dist/workspace-config-policy.d.ts.map +1 -1
- package/dist/workspace-config-policy.js +135 -42
- package/executors.json +2 -0
- package/managed/raw/envrc +24 -0
- package/managed/raw/patches/nx@24.0.3.patch +1179 -133
- package/managed/raw/patches/ttsc@0.37.1.patch +1055 -0
- package/managed/raw/tooling/direnv/developer-links.ts +105 -11
- package/managed/raw/tooling/direnv/devenv.smoo.nix +20 -19
- package/package.json +67 -11
- package/runtime/nx-publish/.build-inputs.json +2 -2
- package/runtime/nx-publish/cache_adapter.js +293 -3
- package/runtime/nx-publish/nx_publish.js +36 -14
- package/src/built-output-packages.ts +1 -1
- package/src/cargo-closure-input.ts +1 -1
- package/src/cargo-source-hash.ts +16 -132
- package/src/cargo-toolchain-paths.ts +2 -2
- package/src/cargo-workspace.ts +1 -2
- package/src/executors/bounded-exec/admission-queue.ts +11 -10
- package/src/executors/bounded-exec/awake-clock.ts +20 -0
- package/src/executors/bounded-exec/bounds.ts +28 -15
- package/src/executors/bounded-exec/case-gate.ts +365 -0
- package/src/executors/bounded-exec/cpu-pool-thread.ts +3 -3
- package/src/executors/bounded-exec/cpu-pool.ts +139 -12
- package/src/executors/bounded-exec/endpoint-life.ts +279 -0
- package/src/executors/bounded-exec/executor.ts +280 -106
- package/src/executors/bounded-exec/gateway-lease.ts +6 -0
- package/src/executors/bounded-exec/go-run-summary.ts +137 -0
- package/src/executors/bounded-exec/hang-diagnostics.ts +70 -52
- package/src/executors/bounded-exec/lease-wait.ts +1 -0
- package/src/executors/bounded-exec/mbx-pool.ts +36 -9
- package/src/executors/bounded-exec/mbx-reservations.ts +213 -182
- package/src/executors/bounded-exec/parent-grant.ts +3 -0
- package/src/executors/bounded-exec/pool-admission.ts +59 -2
- package/src/executors/bounded-exec/progress.ts +37 -2
- package/src/executors/bounded-exec/reservation-connection.ts +221 -0
- package/src/executors/bounded-exec/run-cpu-pool.ts +2 -0
- package/src/executors/bounded-exec/runner-sizing.ts +13 -8
- package/src/executors/bounded-exec/schema.json +1 -1
- package/src/executors/bounded-exec/schema.ts +2 -2
- package/src/executors/bounded-exec/suite-minimum.ts +81 -0
- package/src/executors/bounded-exec/test-result-writer.ts +3 -0
- package/src/executors/bounded-exec/test-results.ts +5 -0
- package/src/executors/bounded-exec/verdict.ts +39 -6
- package/src/executors/cargo-zigbuild/executor.ts +30 -19
- package/src/index.ts +112 -78
- package/src/managed-files/ci-workflow.ts +13 -17
- package/src/managed-files/files.ts +3 -3
- package/src/workspace-config-policy.ts +161 -43
- package/test-timings.json +157 -147
- package/managed/raw/patches/ttsc@0.36.3.patch +0 -1660
|
@@ -972,7 +972,7 @@ index af7da5654b807f8e9d8693cd45aad32a162a4765..6bdfade7ca1d18fa7c9fc072ad1a924d
|
|
|
972
972
|
* The operating system refused the connection. Most often the socket belongs to
|
|
973
973
|
* another user, which is the guarantee the owner-only socket directory buys —
|
|
974
974
|
diff --git a/dist/src/daemon/client/daemon-environment.d.ts b/dist/src/daemon/client/daemon-environment.d.ts
|
|
975
|
-
index 65ae9cfd686c3c676cf321cf402bbbf03fc87dab..
|
|
975
|
+
index 65ae9cfd686c3c676cf321cf402bbbf03fc87dab..7e79adfe9efef8a58674757be0380f6e9c34f043 100644
|
|
976
976
|
--- a/dist/src/daemon/client/daemon-environment.d.ts
|
|
977
977
|
+++ b/dist/src/daemon/client/daemon-environment.d.ts
|
|
978
978
|
@@ -3,7 +3,9 @@
|
|
@@ -986,7 +986,7 @@ index 65ae9cfd686c3c676cf321cf402bbbf03fc87dab..9a68ae94318403ce70aef08f08a3af9c
|
|
|
986
986
|
*/
|
|
987
987
|
export declare function hashDaemonClientEnv(): string;
|
|
988
988
|
export declare function getDaemonEnv(): NodeJS.ProcessEnv & {
|
|
989
|
-
@@ -63,12 +65,
|
|
989
|
+
@@ -63,12 +65,32 @@ export declare function getAppliedDaemonClientEnv(): {
|
|
990
990
|
*/
|
|
991
991
|
export declare function applyDaemonEnvFromClient(newEnv: NodeJS.ProcessEnv): string[];
|
|
992
992
|
/**
|
|
@@ -1016,13 +1016,17 @@ index 65ae9cfd686c3c676cf321cf402bbbf03fc87dab..9a68ae94318403ce70aef08f08a3af9c
|
|
|
1016
1016
|
+ * `bun-node-<hash>` directory whose `node` is Bun, puts it on PATH and names
|
|
1017
1017
|
+ * it in NODE; that directory leaves PATH with NODE when its `node` is the one
|
|
1018
1018
|
+ * PATH resolves. Any other NODE stays, and so does every other PATH entry.
|
|
1019
|
+
+ * - A run's mbx reservation endpoint (`MBX_RESERVATIONS_SOCKET`, or
|
|
1020
|
+
+ * `BOUNDED_EXEC_RESERVATIONS_UNSERVED` when it did not start): the endpoint
|
|
1021
|
+
+ * of one Nx run, fresh for each, which every task inherits and no plugin
|
|
1022
|
+
+ * reads. It leaves the identity; the daemon still receives it.
|
|
1019
1023
|
+ * The order of the remaining PATH entries is kept. Returns a copy; never
|
|
1020
1024
|
+ * mutates runtime env.
|
|
1021
1025
|
*/
|
|
1022
1026
|
export declare function normalizeDaemonEnvironmentForGraph(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): NodeJS.ProcessEnv;
|
|
1023
1027
|
export declare function getChangedEnvKeys(before: NodeJS.ProcessEnv, after: NodeJS.ProcessEnv): string[];
|
|
1024
1028
|
diff --git a/dist/src/daemon/client/daemon-environment.js b/dist/src/daemon/client/daemon-environment.js
|
|
1025
|
-
index 427ced7822fb05ba966d0543c224c5760b016572..
|
|
1029
|
+
index 427ced7822fb05ba966d0543c224c5760b016572..4f07a52210d000864d12dcc4a5bdff55b5ee5bcb 100644
|
|
1026
1030
|
--- a/dist/src/daemon/client/daemon-environment.js
|
|
1027
1031
|
+++ b/dist/src/daemon/client/daemon-environment.js
|
|
1028
1032
|
@@ -8,7 +8,10 @@ exports.getAppliedDaemonClientEnv = getAppliedDaemonClientEnv;
|
|
@@ -1056,10 +1060,20 @@ index 427ced7822fb05ba966d0543c224c5760b016572..303548db369472e0f99f31c3bc66ae9b
|
|
|
1056
1060
|
}
|
|
1057
1061
|
/**
|
|
1058
1062
|
* `NX_LOAD_DOT_ENV_FILES` as its meaning rather than its spelling. `run-command`
|
|
1059
|
-
@@ -
|
|
1060
|
-
return [...changedKeys];
|
|
1063
|
+
@@ -380,35 +385,185 @@ function applyDaemonEnvFromClient(newEnv) {
|
|
1061
1064
|
}
|
|
1062
1065
|
const BERRY_BIN_FOLDER_GRAPH_IDENTITY = '<YARN_BERRY_BIN_FOLDER>';
|
|
1066
|
+
/**
|
|
1067
|
+
- * Yarn Berry creates a fresh BERRY_BIN_FOLDER for every invocation and puts it
|
|
1068
|
+
- * first on PATH. The wrappers inside are runtime state the daemon and workers
|
|
1069
|
+
- * must receive, but the folder's random name is not project-graph identity:
|
|
1070
|
+
- * two invocations whose environments differ only by it would compute the same
|
|
1071
|
+
- * graph. Strips the folder from PATH and pins the var to a sentinel so such
|
|
1072
|
+
- * environments compare equal. Returns a copy; never mutates runtime env.
|
|
1073
|
+
+ * What a run's task hooks publish for its tasks: the endpoint of the run's mbx
|
|
1074
|
+
+ * reservations, or why it has none. Fresh for each run, and read by no plugin.
|
|
1075
|
+
+ */
|
|
1076
|
+
+const RUN_RESERVATION_ENV = ['MBX_RESERVATIONS_SOCKET', 'BOUNDED_EXEC_RESERVATIONS_UNSERVED'];
|
|
1063
1077
|
+/** The directory Bun makes for one run when it finds no `node` on PATH. */
|
|
1064
1078
|
+const BUN_NODE_SHIM = /^bun-node-[0-9a-f]+$/;
|
|
1065
1079
|
+/** Errors that prove a path names nothing; any other leaves it unknown. */
|
|
@@ -1142,13 +1156,7 @@ index 427ced7822fb05ba966d0543c224c5760b016572..303548db369472e0f99f31c3bc66ae9b
|
|
|
1142
1156
|
+ }
|
|
1143
1157
|
+ return { workspace: locate(workspaceRoot, paths), entries: located, resolvedNode };
|
|
1144
1158
|
+}
|
|
1145
|
-
|
|
1146
|
-
- * Yarn Berry creates a fresh BERRY_BIN_FOLDER for every invocation and puts it
|
|
1147
|
-
- * first on PATH. The wrappers inside are runtime state the daemon and workers
|
|
1148
|
-
- * must receive, but the folder's random name is not project-graph identity:
|
|
1149
|
-
- * two invocations whose environments differ only by it would compute the same
|
|
1150
|
-
- * graph. Strips the folder from PATH and pins the var to a sentinel so such
|
|
1151
|
-
- * environments compare equal. Returns a copy; never mutates runtime env.
|
|
1159
|
+
+/**
|
|
1152
1160
|
+ * An env as project-graph identity: the env without what a package manager
|
|
1153
1161
|
+ * adds to run one command in this workspace. The daemon and its workers still
|
|
1154
1162
|
+ * receive all of it, but two clients whose envs differ only by it compute the
|
|
@@ -1169,6 +1177,10 @@ index 427ced7822fb05ba966d0543c224c5760b016572..303548db369472e0f99f31c3bc66ae9b
|
|
|
1169
1177
|
+ * `bun-node-<hash>` directory whose `node` is Bun, puts it on PATH and names
|
|
1170
1178
|
+ * it in NODE; that directory leaves PATH with NODE when its `node` is the one
|
|
1171
1179
|
+ * PATH resolves. Any other NODE stays, and so does every other PATH entry.
|
|
1180
|
+
+ * - A run's mbx reservation endpoint (`MBX_RESERVATIONS_SOCKET`, or
|
|
1181
|
+
+ * `BOUNDED_EXEC_RESERVATIONS_UNSERVED` when it did not start): the endpoint
|
|
1182
|
+
+ * of one Nx run, fresh for each, which every task inherits and no plugin
|
|
1183
|
+
+ * reads. It leaves the identity; the daemon still receives it.
|
|
1172
1184
|
+ * The order of the remaining PATH entries is kept. Returns a copy; never
|
|
1173
1185
|
+ * mutates runtime env.
|
|
1174
1186
|
*/
|
|
@@ -1191,6 +1203,17 @@ index 427ced7822fb05ba966d0543c224c5760b016572..303548db369472e0f99f31c3bc66ae9b
|
|
|
1191
1203
|
+ if (normalized.BERRY_BIN_FOLDER) {
|
|
1192
1204
|
+ scaffolding.add(canonicalize(normalized.BERRY_BIN_FOLDER));
|
|
1193
1205
|
+ normalized.BERRY_BIN_FOLDER = BERRY_BIN_FOLDER_GRAPH_IDENTITY;
|
|
1206
|
+
}
|
|
1207
|
+
- const pathKey = Object.keys(normalized).find((key) => key.toUpperCase() === 'PATH');
|
|
1208
|
+
- if (pathKey && normalized[pathKey]) {
|
|
1209
|
+
- const pathDelimiter = platform === 'win32' ? ';' : ':';
|
|
1210
|
+
- const canonicalize = (value) => {
|
|
1211
|
+
- const withPlatformSeparators = platform === 'win32' ? value.replaceAll('/', '\\') : value;
|
|
1212
|
+
- return platform === 'win32'
|
|
1213
|
+
- ? withPlatformSeparators.toLowerCase()
|
|
1214
|
+
- : withPlatformSeparators;
|
|
1215
|
+
+ for (const key of RUN_RESERVATION_ENV) {
|
|
1216
|
+
+ delete normalized[key];
|
|
1194
1217
|
+ }
|
|
1195
1218
|
+ if (normalized.NODE && facts.resolvedNode !== undefined) {
|
|
1196
1219
|
+ const node = canonicalize(normalized.NODE);
|
|
@@ -1205,15 +1228,7 @@ index 427ced7822fb05ba966d0543c224c5760b016572..303548db369472e0f99f31c3bc66ae9b
|
|
|
1205
1228
|
+ }
|
|
1206
1229
|
+ delete normalized.NODE;
|
|
1207
1230
|
+ }
|
|
1208
|
-
|
|
1209
|
-
- const pathKey = Object.keys(normalized).find((key) => key.toUpperCase() === 'PATH');
|
|
1210
|
-
- if (pathKey && normalized[pathKey]) {
|
|
1211
|
-
- const pathDelimiter = platform === 'win32' ? ';' : ':';
|
|
1212
|
-
- const canonicalize = (value) => {
|
|
1213
|
-
- const withPlatformSeparators = platform === 'win32' ? value.replaceAll('/', '\\') : value;
|
|
1214
|
-
- return platform === 'win32'
|
|
1215
|
-
- ? withPlatformSeparators.toLowerCase()
|
|
1216
|
-
- : withPlatformSeparators;
|
|
1231
|
+
+ }
|
|
1217
1232
|
+ if (entries.length > 0) {
|
|
1218
1233
|
+ const within = (path, directory) => path === directory ||
|
|
1219
1234
|
+ path.startsWith(directory.endsWith(paths.sep) ? directory : directory + paths.sep);
|
|
@@ -1791,7 +1806,7 @@ index 63638e921d68af659ca03f65e82a98c1e2e3f853..b329afc3da3053a3460c44c6ae671304
|
|
|
1791
1806
|
* Applies changes a caller learned of on its own to the workspace context,
|
|
1792
1807
|
* then schedules the recomputation as for a batch the context applied.
|
|
1793
1808
|
diff --git a/dist/src/daemon/server/project-graph-incremental-recomputation.js b/dist/src/daemon/server/project-graph-incremental-recomputation.js
|
|
1794
|
-
index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..
|
|
1809
|
+
index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..af5865170398b5da1cd43ef4f1e6118e1d77a12b 100644
|
|
1795
1810
|
--- a/dist/src/daemon/server/project-graph-incremental-recomputation.js
|
|
1796
1811
|
+++ b/dist/src/daemon/server/project-graph-incremental-recomputation.js
|
|
1797
1812
|
@@ -4,6 +4,7 @@ exports.currentSourceMaps = exports.currentProjectGraph = exports.currentProject
|
|
@@ -1835,7 +1850,7 @@ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..8e3192fef166f49c246aef0ff87b4084
|
|
|
1835
1850
|
}
|
|
1836
1851
|
async function getCachedSerializedProjectGraphPromise(socket) {
|
|
1837
1852
|
// Subscribe the requesting client to the graph-construction topic
|
|
1838
|
-
@@ -238,
|
|
1853
|
+
@@ -238,11 +240,18 @@ function summarize(files) {
|
|
1839
1854
|
}
|
|
1840
1855
|
/**
|
|
1841
1856
|
* Takes in changes the workspace context handed out: restarts the daemon if
|
|
@@ -1850,13 +1865,13 @@ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..8e3192fef166f49c246aef0ff87b4084
|
|
|
1850
1865
|
+ const changed = (0, restart_checks_1.changedPaths)(batch);
|
|
1851
1866
|
+ if ((0, restart_checks_1.restartDaemonIfIgnoreFilesChanged)(changed) ||
|
|
1852
1867
|
+ (0, restart_checks_1.restartDaemonIfLockFilesChanged)(changed)) {
|
|
1868
|
+
+ return;
|
|
1869
|
+
+ }
|
|
1870
|
+
+ if ((0, local_plugin_source_1.invalidateLocalPluginSources)(workspace_root_1.workspaceRoot, changed)) {
|
|
1853
1871
|
return;
|
|
1854
1872
|
}
|
|
1855
|
-
+ (0, local_plugin_source_1.invalidateLocalPluginSources)(workspace_root_1.workspaceRoot, changed);
|
|
1856
1873
|
logger_1.serverLogger.watcherLog(`File changes detected (seq ${batch.seq}):\n` +
|
|
1857
|
-
|
|
1858
|
-
`Updated:\n${summarize((0, restart_checks_1.fileNames)(batch.updatedFiles))}\n` +
|
|
1859
|
-
@@ -268,6 +275,22 @@ async function flushPendingWorkspaceChanges() {
|
|
1874
|
+
@@ -268,6 +277,22 @@ async function flushPendingWorkspaceChanges() {
|
|
1860
1875
|
}
|
|
1861
1876
|
routeAppliedChanges(batch);
|
|
1862
1877
|
}
|
|
@@ -1880,7 +1895,7 @@ index 8f441c4d4258be48c9080b4ae200bf1c0034f3f1..8e3192fef166f49c246aef0ff87b4084
|
|
|
1880
1895
|
* Applies changes a caller learned of on its own to the workspace context,
|
|
1881
1896
|
* then schedules the recomputation as for a batch the context applied.
|
|
1882
1897
|
diff --git a/dist/src/daemon/server/restart-checks.d.ts b/dist/src/daemon/server/restart-checks.d.ts
|
|
1883
|
-
index e99e10b616b35b81b1060b25eeb0acc2351c4776..
|
|
1898
|
+
index e99e10b616b35b81b1060b25eeb0acc2351c4776..66d6e21694a0a8607e7841167dd8d31c2776a5bc 100644
|
|
1884
1899
|
--- a/dist/src/daemon/server/restart-checks.d.ts
|
|
1885
1900
|
+++ b/dist/src/daemon/server/restart-checks.d.ts
|
|
1886
1901
|
@@ -1,6 +1,6 @@
|
|
@@ -1891,7 +1906,7 @@ index e99e10b616b35b81b1060b25eeb0acc2351c4776..e94e74921349d081353fc14498178cce
|
|
|
1891
1906
|
/**
|
|
1892
1907
|
* The daemon's own process file, workspace-relative. It lives under the
|
|
1893
1908
|
* hardcoded-ignored .nx/workspace-data, so the watch admits it explicitly;
|
|
1894
|
-
@@ -15,8 +15,
|
|
1909
|
+
@@ -15,8 +15,25 @@ export declare function changedPaths(batch: ChangeBatch): string[];
|
|
1895
1910
|
* needs a daemon restart to take effect. True when it stopped the daemon.
|
|
1896
1911
|
*/
|
|
1897
1912
|
export declare function restartDaemonIfIgnoreFilesChanged(paths: string[]): boolean;
|
|
@@ -1907,6 +1922,7 @@ index e99e10b616b35b81b1060b25eeb0acc2351c4776..e94e74921349d081353fc14498178cce
|
|
|
1907
1922
|
+export declare function registerDaemonForRestartChecks(server: Server, sockets: Iterable<Socket>, socketPath: string): void;
|
|
1908
1923
|
+export declare function recordInstallationBaseline(): Promise<void>;
|
|
1909
1924
|
+export declare function restartDaemonIfLockFilesChanged(paths: string[]): boolean;
|
|
1925
|
+
+export declare function restartDaemonForLocalPlugins(): void;
|
|
1910
1926
|
/**
|
|
1911
1927
|
* Stops this daemon when the events show another process has written the
|
|
1912
1928
|
* daemon's process file. True when it stopped the daemon.
|
|
@@ -1917,10 +1933,10 @@ index e99e10b616b35b81b1060b25eeb0acc2351c4776..e94e74921349d081353fc14498178cce
|
|
|
1917
1933
|
+/** Stops the daemon, naming `reason` in its log: its file watcher stopped delivering. */
|
|
1918
1934
|
+export declare function stopDaemonForStoppedWatcher(reason: string): void;
|
|
1919
1935
|
diff --git a/dist/src/daemon/server/restart-checks.js b/dist/src/daemon/server/restart-checks.js
|
|
1920
|
-
index e692c3cfc73bacf3252e117d4e895b981412f4b9..
|
|
1936
|
+
index e692c3cfc73bacf3252e117d4e895b981412f4b9..aca2e9b4948f89ef074e1b0ac609bc0805f8e936 100644
|
|
1921
1937
|
--- a/dist/src/daemon/server/restart-checks.js
|
|
1922
1938
|
+++ b/dist/src/daemon/server/restart-checks.js
|
|
1923
|
-
@@ -1,22 +1,
|
|
1939
|
+
@@ -1,22 +1,47 @@
|
|
1924
1940
|
"use strict";
|
|
1925
1941
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1926
1942
|
-exports.relativeServerProcess = void 0;
|
|
@@ -1928,6 +1944,7 @@ index e692c3cfc73bacf3252e117d4e895b981412f4b9..94c06c88dfac8df73dd1c12f5c09b900
|
|
|
1928
1944
|
exports.registerDaemonForRestartChecks = registerDaemonForRestartChecks;
|
|
1929
1945
|
+exports.recordInstallationBaseline = recordInstallationBaseline;
|
|
1930
1946
|
+exports.restartDaemonIfLockFilesChanged = restartDaemonIfLockFilesChanged;
|
|
1947
|
+
+exports.restartDaemonForLocalPlugins = restartDaemonForLocalPlugins;
|
|
1931
1948
|
+exports.stopDaemonIfReplaced = stopDaemonIfReplaced;
|
|
1932
1949
|
+exports.stopDaemonIfOutdated = stopDaemonIfOutdated;
|
|
1933
1950
|
+exports.stopDaemonIfWorkspaceGone = stopDaemonIfWorkspaceGone;
|
|
@@ -1973,7 +1990,7 @@ index e692c3cfc73bacf3252e117d4e895b981412f4b9..94c06c88dfac8df73dd1c12f5c09b900
|
|
|
1973
1990
|
/**
|
|
1974
1991
|
* The daemon's own process file, workspace-relative. It lives under the
|
|
1975
1992
|
* hardcoded-ignored .nx/workspace-data, so the watch admits it explicitly;
|
|
1976
|
-
@@ -45,6 +
|
|
1993
|
+
@@ -45,6 +70,8 @@ const IGNORE_FILE_NAMES = ['.gitignore', '.nxignore'];
|
|
1977
1994
|
* needs a daemon restart to take effect. True when it stopped the daemon.
|
|
1978
1995
|
*/
|
|
1979
1996
|
function restartDaemonIfIgnoreFilesChanged(paths) {
|
|
@@ -1982,7 +1999,7 @@ index e692c3cfc73bacf3252e117d4e895b981412f4b9..94c06c88dfac8df73dd1c12f5c09b900
|
|
|
1982
1999
|
for (const path of paths) {
|
|
1983
2000
|
const basename = path.slice(path.lastIndexOf('/') + 1);
|
|
1984
2001
|
if (IGNORE_FILE_NAMES.includes(basename)) {
|
|
1985
|
-
@@ -54,24 +
|
|
2002
|
+
@@ -54,24 +81,451 @@ function restartDaemonIfIgnoreFilesChanged(paths) {
|
|
1986
2003
|
}
|
|
1987
2004
|
return false;
|
|
1988
2005
|
}
|
|
@@ -2335,6 +2352,12 @@ index e692c3cfc73bacf3252e117d4e895b981412f4b9..94c06c88dfac8df73dd1c12f5c09b900
|
|
|
2335
2352
|
+ restartDaemon('LINKED_PLUGIN_CHANGED', notice);
|
|
2336
2353
|
+}
|
|
2337
2354
|
+// Applied paths have been hashed by the native workspace context; same-byte
|
|
2355
|
+
+// A local plugin this daemon loaded into its own process cannot be evicted, so
|
|
2356
|
+
+// a change to a file it loaded restarts the daemon. Clients wait for the
|
|
2357
|
+
+// successor and resend, as after a lockfile change.
|
|
2358
|
+
+function restartDaemonForLocalPlugins() {
|
|
2359
|
+
+ restartDaemon('LOCAL_PLUGIN_CHANGED');
|
|
2360
|
+
+}
|
|
2338
2361
|
+// rewrites were dropped already. No lockfile is read on this watcher path.
|
|
2339
2362
|
+function restartDaemonIfLockFilesChanged(paths) {
|
|
2340
2363
|
+ if (!paths.some((path) => LOCK_FILE_NAMES.includes(path))) {
|
|
@@ -3012,6 +3035,49 @@ index 3b0c4d67595cbff1d083f21bb6b70abeda8e377e..d87056c79d0097182de7d725a93100ea
|
|
|
3012
3035
|
});
|
|
3013
3036
|
(0, cache_1.deleteDaemonJsonProcessCache)();
|
|
3014
3037
|
(0, get_plugins_1.cleanupPlugins)();
|
|
3038
|
+
diff --git a/dist/src/daemon/server/sync-generators.js b/dist/src/daemon/server/sync-generators.js
|
|
3039
|
+
index 731ba638ab39ae3babe35db7d98ee9e66995b62f..78c9296b4322cfd8fc024a8c26aa6fe036b0ff8c 100644
|
|
3040
|
+
--- a/dist/src/daemon/server/sync-generators.js
|
|
3041
|
+
+++ b/dist/src/daemon/server/sync-generators.js
|
|
3042
|
+
@@ -90,31 +90,13 @@ function collectAndScheduleSyncGenerators(projectGraph) {
|
|
3043
|
+
scheduledGenerators.add(generator);
|
|
3044
|
+
}
|
|
3045
|
+
log('scheduling:', [...scheduledGenerators]);
|
|
3046
|
+
- if (scheduledTimeoutId) {
|
|
3047
|
+
- // we have a scheduled run already, so we don't need to do anything
|
|
3048
|
+
- return;
|
|
3049
|
+
- }
|
|
3050
|
+
- scheduledTimeoutId = setTimeout(async () => {
|
|
3051
|
+
- scheduledTimeoutId = undefined;
|
|
3052
|
+
- if (waitPeriod < 4000) {
|
|
3053
|
+
- waitPeriod = waitPeriod * 2;
|
|
3054
|
+
- }
|
|
3055
|
+
- if (scheduledGenerators.size === 0) {
|
|
3056
|
+
- // no generators to run
|
|
3057
|
+
- return;
|
|
3058
|
+
- }
|
|
3059
|
+
- // Fetch the latest graph instead of using the captured one which might be stale
|
|
3060
|
+
- const { projectGraph: latestGraph, error } = await (0, project_graph_incremental_recomputation_1.getCachedSerializedProjectGraphPromise)();
|
|
3061
|
+
- if (!latestGraph || error) {
|
|
3062
|
+
- log('Cannot run scheduled generators: graph unavailable or errored');
|
|
3063
|
+
- return;
|
|
3064
|
+
- }
|
|
3065
|
+
- const { projects } = (0, project_graph_1.readProjectsConfigurationFromProjectGraph)(latestGraph);
|
|
3066
|
+
- for (const generator of scheduledGenerators) {
|
|
3067
|
+
- syncGeneratorsCacheResultPromises.set(generator, runGenerator(generator, projects));
|
|
3068
|
+
- }
|
|
3069
|
+
- await Promise.all(syncGeneratorsCacheResultPromises.values());
|
|
3070
|
+
- }, waitPeriod);
|
|
3071
|
+
+ // Nothing runs here. A generator left in `scheduledGenerators` is stale, and
|
|
3072
|
+
+ // runs when a client asks for its changes (getFromCacheOrRunGenerators) against
|
|
3073
|
+
+ // the graph that is current then. Running each one 100 ms after every graph
|
|
3074
|
+
+ // recomputation put its synchronous work on the daemon's one event loop while
|
|
3075
|
+
+ // the client that caused the recomputation waited for its graph: 2.4 s of a cold
|
|
3076
|
+
+ // daemon's first project graph for `managed-files`, in a workspace whose clients
|
|
3077
|
+
+ // never ask for its sync changes.
|
|
3078
|
+
}
|
|
3079
|
+
async function getCachedRegisteredSyncGenerators() {
|
|
3080
|
+
log('get registered sync generators');
|
|
3015
3081
|
diff --git a/dist/src/daemon/socket-utils.d.ts b/dist/src/daemon/socket-utils.d.ts
|
|
3016
3082
|
index fb36b09efa216204d5148f5e6c1fc68f462a4929..ad6409689f42cd37e00acb2488972005a9d9f667 100644
|
|
3017
3083
|
--- a/dist/src/daemon/socket-utils.d.ts
|
|
@@ -3098,6 +3164,330 @@ index 3aed2d0e8233491ed17cf2659fc44bd3ed74eac9..cc914c2dd0755a3ee555805b4ed085eb
|
|
|
3098
3164
|
// Prepare a serialized project graph result for sending over IPC from the server to the client
|
|
3099
3165
|
function serializeResult(error, serializedProjectGraph, serializedSourceMaps) {
|
|
3100
3166
|
// We do not want to repeat work `JSON.stringify`ing an object containing the potentially large project graph so merge as strings
|
|
3167
|
+
diff --git a/dist/src/daemon/tmp-dir.js b/dist/src/daemon/tmp-dir.js
|
|
3168
|
+
index 400e96394bbef2f44ca626a1d9445bd539674068..f31f54daa6b87d595fdf6384778313e8f5b8ecaf 100644
|
|
3169
|
+
--- a/dist/src/daemon/tmp-dir.js
|
|
3170
|
+
+++ b/dist/src/daemon/tmp-dir.js
|
|
3171
|
+
@@ -224,20 +224,28 @@ function assertWithinBudget(details) {
|
|
3172
|
+
`The directory set in NX_SOCKET_DIR (${details.refusedConfiguredDir}) could not be used — see the warning above — so Nx fell back to a longer path.\nPoint NX_SOCKET_DIR at a short directory your user owns.`,
|
|
3173
|
+
].join('\n'), cause === undefined ? undefined : { cause });
|
|
3174
|
+
}
|
|
3175
|
+
+/*
|
|
3176
|
+
+ * Every resolver below hands the native side `process.env`, the environment Nx
|
|
3177
|
+
+ * reads its configuration from everywhere else. Given none, the native side
|
|
3178
|
+
+ * reads the C environment, which under Bun an assignment to `process.env` never
|
|
3179
|
+
+ * reaches: a Bun process that points `process.env.NX_SOCKET_DIR` at another
|
|
3180
|
+
+ * workspace (a wrapper entered from another workspace's shell) would bind its
|
|
3181
|
+
+ * plugin workers in the directory it inherited.
|
|
3182
|
+
+ */
|
|
3183
|
+
/** The daemon's own socket. */
|
|
3184
|
+
function getDaemonSocketPath() {
|
|
3185
|
+
- return adopt((0, native_1.resolveDaemonSocketPath)(workspace_root_1.workspaceRoot));
|
|
3186
|
+
+ return adopt((0, native_1.resolveDaemonSocketPath)(workspace_root_1.workspaceRoot, process.env));
|
|
3187
|
+
}
|
|
3188
|
+
/** A forked task process's socket, in the daemon's per-run directory. */
|
|
3189
|
+
function getForkedProcessSocketPath(id) {
|
|
3190
|
+
- return adopt((0, native_1.resolveForkedProcessSocketPath)(workspace_root_1.workspaceRoot, id));
|
|
3191
|
+
+ return adopt((0, native_1.resolveForkedProcessSocketPath)(workspace_root_1.workspaceRoot, id, process.env));
|
|
3192
|
+
}
|
|
3193
|
+
/**
|
|
3194
|
+
* Plugin worker sockets get their own workspace-scoped directory rather than
|
|
3195
|
+
* sitting in the shared system temp dir, which cannot be locked down.
|
|
3196
|
+
*/
|
|
3197
|
+
function getPluginSocketPath(id) {
|
|
3198
|
+
- return adopt((0, native_1.resolvePluginSocketPath)(workspace_root_1.workspaceRoot, id));
|
|
3199
|
+
+ return adopt((0, native_1.resolvePluginSocketPath)(workspace_root_1.workspaceRoot, id, process.env));
|
|
3200
|
+
}
|
|
3201
|
+
/**
|
|
3202
|
+
* Where the Nx Console socket lives, for whoever binds or connects to it.
|
|
3203
|
+
@@ -251,12 +259,12 @@ function getPluginSocketPath(id) {
|
|
3204
|
+
* load a workspace `.env` into a copy rather than into `process.env`
|
|
3205
|
+
*/
|
|
3206
|
+
function getNxConsoleSocketPath(workspaceRootOverride, env) {
|
|
3207
|
+
- return adopt((0, native_1.resolveNxConsoleSocketPath)(workspaceRootOverride ?? workspace_root_1.workspaceRoot, env));
|
|
3208
|
+
+ return adopt((0, native_1.resolveNxConsoleSocketPath)(workspaceRootOverride ?? workspace_root_1.workspaceRoot, env ?? process.env));
|
|
3209
|
+
}
|
|
3210
|
+
function removeSocketDir() {
|
|
3211
|
+
try {
|
|
3212
|
+
// The directory, not the socket: the daemon's whole per-run directory goes.
|
|
3213
|
+
- (0, node_fs_1.rmSync)((0, native_1.resolveDaemonSocketPath)(workspace_root_1.workspaceRoot).dir, {
|
|
3214
|
+
+ (0, node_fs_1.rmSync)((0, native_1.resolveDaemonSocketPath)(workspace_root_1.workspaceRoot, process.env).dir, {
|
|
3215
|
+
recursive: true,
|
|
3216
|
+
force: true,
|
|
3217
|
+
});
|
|
3218
|
+
diff --git a/dist/src/executors/run-commands/running-tasks.d.ts b/dist/src/executors/run-commands/running-tasks.d.ts
|
|
3219
|
+
index 9813a098eb17d9e799e1583a848f4e2fce945b6f..3d5dfcfc981cac0540758d15fd3fc7a600a2d1a6 100644
|
|
3220
|
+
--- a/dist/src/executors/run-commands/running-tasks.d.ts
|
|
3221
|
+
+++ b/dist/src/executors/run-commands/running-tasks.d.ts
|
|
3222
|
+
@@ -36,6 +36,7 @@ export declare class SeriallyRunningTasks implements RunningTask {
|
|
3223
|
+
private code;
|
|
3224
|
+
private error;
|
|
3225
|
+
private outputCallbacks;
|
|
3226
|
+
+ private killSignal;
|
|
3227
|
+
private exited;
|
|
3228
|
+
private exitTerminalOutput;
|
|
3229
|
+
constructor(options: NormalizedRunCommandsOptions, context: ExecutorContext, tuiEnabled: boolean, task: Pick<Task, 'id' | 'ultracache'>, baseEnv?: NodeJS.ProcessEnv);
|
|
3230
|
+
diff --git a/dist/src/executors/run-commands/running-tasks.js b/dist/src/executors/run-commands/running-tasks.js
|
|
3231
|
+
index be662a6ea68d9df1a606795b2b39934740467d54..17f40095c4eb0963d704d6fdb16fc5951e0e3b4e 100644
|
|
3232
|
+
--- a/dist/src/executors/run-commands/running-tasks.js
|
|
3233
|
+
+++ b/dist/src/executors/run-commands/running-tasks.js
|
|
3234
|
+
@@ -14,6 +14,7 @@ const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
|
|
3235
|
+
const task_env_1 = require("../../tasks-runner/task-env");
|
|
3236
|
+
const tokens_1 = require("../../tasks-runner/tokens");
|
|
3237
|
+
const task_io_service_1 = require("../../tasks-runner/task-io-service");
|
|
3238
|
+
+const child_process_2 = require("../../utils/child-process");
|
|
3239
|
+
const exit_codes_1 = require("../../utils/exit-codes");
|
|
3240
|
+
const output_1 = require("../../utils/output");
|
|
3241
|
+
/**
|
|
3242
|
+
@@ -110,6 +111,12 @@ class ParallelRunningTasks {
|
|
3243
|
+
}
|
|
3244
|
+
});
|
|
3245
|
+
childProcess.onExit((code, terminalOutput) => {
|
|
3246
|
+
+ // A failed command reports only once its output is read, so
|
|
3247
|
+
+ // readyWhen text a sibling prints meanwhile must not hide it.
|
|
3248
|
+
+ if (code === 0 &&
|
|
3249
|
+
+ this.childProcesses.some((p) => p !== childProcess && p.exitedWithFailure)) {
|
|
3250
|
+
+ return;
|
|
3251
|
+
+ }
|
|
3252
|
+
res({
|
|
3253
|
+
childProcess,
|
|
3254
|
+
result: { code, terminalOutput },
|
|
3255
|
+
@@ -137,9 +144,14 @@ class ParallelRunningTasks {
|
|
3256
|
+
}
|
|
3257
|
+
else {
|
|
3258
|
+
const runningProcesses = new Set();
|
|
3259
|
+
- let hasFailure = false;
|
|
3260
|
+
- let failureDetails = null;
|
|
3261
|
+
+ let failedProcess = null;
|
|
3262
|
+
const terminalOutputs = new Map();
|
|
3263
|
+
+ const failFast = (childProcess) => {
|
|
3264
|
+
+ if (failedProcess)
|
|
3265
|
+
+ return;
|
|
3266
|
+
+ failedProcess = childProcess;
|
|
3267
|
+
+ this.terminateRemainingProcesses(runningProcesses, childProcess);
|
|
3268
|
+
+ };
|
|
3269
|
+
await Promise.allSettled(this.childProcesses.map(async (childProcess) => {
|
|
3270
|
+
runningProcesses.add(childProcess);
|
|
3271
|
+
childProcess.onOutput((terminalOutput) => {
|
|
3272
|
+
@@ -147,20 +159,20 @@ class ParallelRunningTasks {
|
|
3273
|
+
cb(terminalOutput);
|
|
3274
|
+
}
|
|
3275
|
+
});
|
|
3276
|
+
+ // Results wait for the output to drain, which a descendant holding
|
|
3277
|
+
+ // the pipes can stretch to a second.
|
|
3278
|
+
+ childProcess.onFailedExit(() => failFast(childProcess));
|
|
3279
|
+
const { code, terminalOutput } = await childProcess.getResults();
|
|
3280
|
+
terminalOutputs.set(childProcess, terminalOutput);
|
|
3281
|
+
- if (code !== 0 && !hasFailure) {
|
|
3282
|
+
- hasFailure = true;
|
|
3283
|
+
- failureDetails = { childProcess, code, terminalOutput };
|
|
3284
|
+
- // Immediately terminate all other running processes
|
|
3285
|
+
- this.terminateRemainingProcesses(runningProcesses, childProcess);
|
|
3286
|
+
+ if (code !== 0) {
|
|
3287
|
+
+ failFast(childProcess);
|
|
3288
|
+
}
|
|
3289
|
+
runningProcesses.delete(childProcess);
|
|
3290
|
+
}));
|
|
3291
|
+
let terminalOutput = Array.from(terminalOutputs.values()).join('\r\n');
|
|
3292
|
+
- if (hasFailure && failureDetails) {
|
|
3293
|
+
+ if (failedProcess) {
|
|
3294
|
+
// Add failure message
|
|
3295
|
+
- const warning = commandExitedNonZeroWarning(failureDetails.childProcess.command);
|
|
3296
|
+
+ const warning = commandExitedNonZeroWarning(failedProcess.command);
|
|
3297
|
+
terminalOutput += warning;
|
|
3298
|
+
streamChunk(warning, this.streamOutput, process.stderr);
|
|
3299
|
+
this.emitExit(1, terminalOutput);
|
|
3300
|
+
@@ -186,6 +198,9 @@ class SeriallyRunningTasks {
|
|
3301
|
+
this.baseEnv = baseEnv;
|
|
3302
|
+
this.terminalOutputChunks = [];
|
|
3303
|
+
this.currentProcess = null;
|
|
3304
|
+
+ // A command can be killed after it exits, while its output drains. The
|
|
3305
|
+
+ // signal then reaches no process, so this is what stops the next command.
|
|
3306
|
+
+ this.killSignal = null;
|
|
3307
|
+
this.exitCallbacks = [];
|
|
3308
|
+
this.code = 0;
|
|
3309
|
+
this.outputCallbacks = [];
|
|
3310
|
+
@@ -253,10 +268,15 @@ class SeriallyRunningTasks {
|
|
3311
|
+
throw new Error('Not implemented');
|
|
3312
|
+
}
|
|
3313
|
+
kill(signal) {
|
|
3314
|
+
+ this.killSignal = signal ?? 'SIGTERM';
|
|
3315
|
+
return this.currentProcess?.kill(signal);
|
|
3316
|
+
}
|
|
3317
|
+
async run(options, context) {
|
|
3318
|
+
for (const c of options.commands) {
|
|
3319
|
+
+ if (this.killSignal) {
|
|
3320
|
+
+ this.code = (0, exit_codes_1.signalToCode)(this.killSignal);
|
|
3321
|
+
+ break;
|
|
3322
|
+
+ }
|
|
3323
|
+
const childProcess = await this.createProcess(c, options.color, calculateCwd(options.cwd, context), options.processEnv ?? options.env ?? {}, this.task, options.usePty, options.streamOutput, options.tty, options.envFile, this.baseEnv);
|
|
3324
|
+
this.currentProcess = childProcess;
|
|
3325
|
+
childProcess.onOutput((output, isCommandHeader) => {
|
|
3326
|
+
@@ -349,7 +369,10 @@ class RunningNodeProcess {
|
|
3327
|
+
this.terminalOutputChunks = [];
|
|
3328
|
+
this.exitCallbacks = [];
|
|
3329
|
+
this.outputCallbacks = [];
|
|
3330
|
+
+ this.failedExitCallbacks = [];
|
|
3331
|
+
this.killPromise = null;
|
|
3332
|
+
+ // Set at 'exit', while the output may still be unread.
|
|
3333
|
+
+ this.exitedWithFailure = false;
|
|
3334
|
+
// Memoized exit so late getResults()/onExit() callers don't hang.
|
|
3335
|
+
this.exited = false;
|
|
3336
|
+
this.exitCode = 0;
|
|
3337
|
+
@@ -367,6 +390,7 @@ class RunningNodeProcess {
|
|
3338
|
+
windowsHide: true,
|
|
3339
|
+
stdio: ['inherit', 'pipe', 'pipe'],
|
|
3340
|
+
});
|
|
3341
|
+
+ this.stdioClosed = (0, child_process_2.whenStdioClosed)(this.childProcess);
|
|
3342
|
+
this.closedPromise = new Promise((resolve) => {
|
|
3343
|
+
this.childProcess.on('close', resolve);
|
|
3344
|
+
});
|
|
3345
|
+
@@ -402,6 +426,10 @@ class RunningNodeProcess {
|
|
3346
|
+
}
|
|
3347
|
+
this.exitCallbacks.push(cb);
|
|
3348
|
+
}
|
|
3349
|
+
+ /** Runs at a non-zero 'exit', before the rest of the output is read. */
|
|
3350
|
+
+ onFailedExit(cb) {
|
|
3351
|
+
+ this.failedExitCallbacks.push(cb);
|
|
3352
|
+
+ }
|
|
3353
|
+
send(message) {
|
|
3354
|
+
this.childProcess.send(message);
|
|
3355
|
+
}
|
|
3356
|
+
@@ -424,10 +452,15 @@ class RunningNodeProcess {
|
|
3357
|
+
return this.killPromise;
|
|
3358
|
+
if (!this.childProcess.pid)
|
|
3359
|
+
return Promise.resolve();
|
|
3360
|
+
+ // An exited child's pid is free for reuse, so signalling it could reach an
|
|
3361
|
+
+ // unrelated process.
|
|
3362
|
+
+ const signalled = (0, child_process_2.hasExited)(this.childProcess)
|
|
3363
|
+
+ ? Promise.resolve()
|
|
3364
|
+
+ : (0, native_1.killProcessTreeGraceful)(this.childProcess.pid, signal);
|
|
3365
|
+
// Cache the promise so concurrent callers (e.g. cleanup() after a
|
|
3366
|
+
// fire-and-forget kill from cleanUpUnneededContinuousTasks) await the
|
|
3367
|
+
// same in-progress operation instead of no-oping.
|
|
3368
|
+
- this.killPromise = (0, native_1.killProcessTreeGraceful)(this.childProcess.pid, signal).then(() =>
|
|
3369
|
+
+ this.killPromise = signalled.then(() =>
|
|
3370
|
+
// Wait for stdio drain and close events before the orchestrator
|
|
3371
|
+
// tears down the event loop via process.exit().
|
|
3372
|
+
Promise.race([
|
|
3373
|
+
@@ -451,9 +484,10 @@ class RunningNodeProcess {
|
|
3374
|
+
addListeners(commandConfig) {
|
|
3375
|
+
this.childProcess.stdout.setEncoding('utf8');
|
|
3376
|
+
this.childProcess.stderr.setEncoding('utf8');
|
|
3377
|
+
+ const exitedWithFailure = () => this.exitedWithFailure;
|
|
3378
|
+
// Separate matchers, so a ready string never spans stdout and stderr
|
|
3379
|
+
- const stdoutReady = readyWhenMatcher(this.readyWhenStatus);
|
|
3380
|
+
- const stderrReady = readyWhenMatcher(this.readyWhenStatus);
|
|
3381
|
+
+ const stdoutReady = readyWhenMatcher(this.readyWhenStatus, exitedWithFailure);
|
|
3382
|
+
+ const stderrReady = readyWhenMatcher(this.readyWhenStatus, exitedWithFailure);
|
|
3383
|
+
this.childProcess.stdout.on('data', (data) => {
|
|
3384
|
+
const output = addColorAndPrefix(data, commandConfig);
|
|
3385
|
+
this.terminalOutputChunks.push(output);
|
|
3386
|
+
@@ -485,11 +519,19 @@ class RunningNodeProcess {
|
|
3387
|
+
untrackRunningNodeProcess(this);
|
|
3388
|
+
this.emitExit(1, terminalOutput);
|
|
3389
|
+
});
|
|
3390
|
+
- this.childProcess.on('exit', (code, signal) => {
|
|
3391
|
+
+ this.childProcess.on('exit', async (code, signal) => {
|
|
3392
|
+
if (code === null) {
|
|
3393
|
+
code = (0, exit_codes_1.signalToCode)(signal);
|
|
3394
|
+
}
|
|
3395
|
+
untrackRunningNodeProcess(this);
|
|
3396
|
+
+ this.exitedWithFailure = code !== 0;
|
|
3397
|
+
+ if (this.exitedWithFailure) {
|
|
3398
|
+
+ for (const cb of this.failedExitCallbacks) {
|
|
3399
|
+
+ cb();
|
|
3400
|
+
+ }
|
|
3401
|
+
+ }
|
|
3402
|
+
+ // The last stdout and stderr chunks can still be unread at 'exit'.
|
|
3403
|
+
+ await this.stdioClosed;
|
|
3404
|
+
if (code === 0 &&
|
|
3405
|
+
this.readyWhenStatus.length &&
|
|
3406
|
+
!isReady(this.readyWhenStatus)) {
|
|
3407
|
+
@@ -591,23 +633,33 @@ function isReady(readyWhenStatus) {
|
|
3408
|
+
// The output as printed, kept across chunks, matches strings that hold escape
|
|
3409
|
+
// sequences. LogMatcher, absent from the WASM binding, matches text with
|
|
3410
|
+
// escapes inside it.
|
|
3411
|
+
-function readyWhenMatcher(readyWhenStatus) {
|
|
3412
|
+
+function readyWhenMatcher(readyWhenStatus, exitedWithFailure) {
|
|
3413
|
+
const matchers = readyWhenStatus.map((status) => ({
|
|
3414
|
+
status,
|
|
3415
|
+
matcher: native_1.IS_WASM ? null : new native_1.LogMatcher([status.stringToMatch]),
|
|
3416
|
+
tail: '',
|
|
3417
|
+
+ matched: false,
|
|
3418
|
+
}));
|
|
3419
|
+
return (chunk) => {
|
|
3420
|
+
+ // The status is shared, so only a chunk with this command's own match
|
|
3421
|
+
+ // reports ready. Once ready, only a failed command can change the result.
|
|
3422
|
+
+ if (isReady(readyWhenStatus) && !exitedWithFailure())
|
|
3423
|
+
+ return false;
|
|
3424
|
+
+ let matchedNow = false;
|
|
3425
|
+
for (const entry of matchers) {
|
|
3426
|
+
const { status, matcher } = entry;
|
|
3427
|
+
- if (status.found)
|
|
3428
|
+
+ if (entry.matched)
|
|
3429
|
+
continue;
|
|
3430
|
+
const printed = entry.tail + chunk;
|
|
3431
|
+
- status.found =
|
|
3432
|
+
+ entry.matched =
|
|
3433
|
+
printed.includes(status.stringToMatch) || !!matcher?.feed(chunk);
|
|
3434
|
+
entry.tail = printed.slice(Math.max(0, printed.length - status.stringToMatch.length + 1));
|
|
3435
|
+
+ if (entry.matched) {
|
|
3436
|
+
+ status.found = true;
|
|
3437
|
+
+ matchedNow = true;
|
|
3438
|
+
+ }
|
|
3439
|
+
}
|
|
3440
|
+
- return isReady(readyWhenStatus);
|
|
3441
|
+
+ return matchedNow && isReady(readyWhenStatus);
|
|
3442
|
+
};
|
|
3443
|
+
}
|
|
3444
|
+
function loadEnvVarsFile(path, env = {}) {
|
|
3445
|
+
diff --git a/dist/src/executors/run-script/run-script.impl.js b/dist/src/executors/run-script/run-script.impl.js
|
|
3446
|
+
index 196ee42030c875ceb3d734d9e26ed3b64b47c9b7..4ed3d5227987b9e1531cfed4fb42045b023c4544 100644
|
|
3447
|
+
--- a/dist/src/executors/run-script/run-script.impl.js
|
|
3448
|
+
+++ b/dist/src/executors/run-script/run-script.impl.js
|
|
3449
|
+
@@ -6,6 +6,7 @@ const child_process_1 = require("child_process");
|
|
3450
|
+
const path = tslib_1.__importStar(require("path"));
|
|
3451
|
+
const native_1 = require("../../native");
|
|
3452
|
+
const pseudo_terminal_1 = require("../../tasks-runner/pseudo-terminal");
|
|
3453
|
+
+const child_process_2 = require("../../utils/child-process");
|
|
3454
|
+
const package_manager_1 = require("../../utils/package-manager");
|
|
3455
|
+
async function default_1(options, context) {
|
|
3456
|
+
const pm = (0, package_manager_1.getPackageManagerCommand)();
|
|
3457
|
+
@@ -40,13 +41,16 @@ function nodeProcess(command, cwd, env) {
|
|
3458
|
+
env,
|
|
3459
|
+
windowsHide: true,
|
|
3460
|
+
});
|
|
3461
|
+
+ const stdioClosed = (0, child_process_2.whenStdioClosed)(cp);
|
|
3462
|
+
// Forward stdout/stderr to parent process
|
|
3463
|
+
cp.stdout.pipe(process.stdout);
|
|
3464
|
+
cp.stderr.pipe(process.stderr);
|
|
3465
|
+
cp.on('error', (error) => {
|
|
3466
|
+
rej(error);
|
|
3467
|
+
});
|
|
3468
|
+
- cp.on('exit', (code) => {
|
|
3469
|
+
+ cp.on('exit', async (code) => {
|
|
3470
|
+
+ // The last stdout and stderr chunks can still be unread at 'exit'.
|
|
3471
|
+
+ await stdioClosed;
|
|
3472
|
+
if (code === 0) {
|
|
3473
|
+
res();
|
|
3474
|
+
}
|
|
3475
|
+
@@ -55,9 +59,13 @@ function nodeProcess(command, cwd, env) {
|
|
3476
|
+
}
|
|
3477
|
+
});
|
|
3478
|
+
const exitHandler = (signal) => {
|
|
3479
|
+
- if (cp && cp.pid && !cp.killed) {
|
|
3480
|
+
+ // An exited child's pid is free for reuse, and its exit code decides
|
|
3481
|
+
+ // the result, also when the kill is what made it exit.
|
|
3482
|
+
+ if (cp && cp.pid && !cp.killed && !(0, child_process_2.hasExited)(cp)) {
|
|
3483
|
+
(0, native_1.killProcessTreeGraceful)(cp.pid, signal).finally(() => {
|
|
3484
|
+
- res();
|
|
3485
|
+
+ if (!(0, child_process_2.hasExited)(cp)) {
|
|
3486
|
+
+ res();
|
|
3487
|
+
+ }
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
};
|
|
3101
3491
|
diff --git a/dist/src/hasher/check-task-files.js b/dist/src/hasher/check-task-files.js
|
|
3102
3492
|
index b027c02a6df7532cce64ae9684bfb76e56bf975b..ce045a0e126de3d349a10d0f367a0bdbbaad820a 100644
|
|
3103
3493
|
--- a/dist/src/hasher/check-task-files.js
|
|
@@ -3176,27 +3566,47 @@ index 1914a3eca8b47318a3aede3990836f5e757501ce..efc124fa0f23869852af305b5e77961a
|
|
|
3176
3566
|
const plansReference = this.planner.getPlansReference(taskIds, taskGraph);
|
|
3177
3567
|
return this.inspector.inspectInputs(plansReference);
|
|
3178
3568
|
}
|
|
3569
|
+
diff --git a/dist/src/hasher/native-task-hasher-impl.d.ts b/dist/src/hasher/native-task-hasher-impl.d.ts
|
|
3570
|
+
index 57d1ce513dfb13aa98579dd4929aaef84a758bf6..2e40f2aa2cf7a01e1f0b31435526c486d80b5043 100644
|
|
3571
|
+
--- a/dist/src/hasher/native-task-hasher-impl.d.ts
|
|
3572
|
+
+++ b/dist/src/hasher/native-task-hasher-impl.d.ts
|
|
3573
|
+
@@ -7,6 +7,7 @@ import type { TaskPlanningContext } from './task-planning-context';
|
|
3574
|
+
import { PartialHash, TaskHasherImpl } from './task-hasher';
|
|
3575
|
+
export declare class NativeTaskHasherImpl implements TaskHasherImpl {
|
|
3576
|
+
private readonly projectGraph;
|
|
3577
|
+
+ private readonly nxJson;
|
|
3578
|
+
hasher: TaskHasher;
|
|
3579
|
+
planner: HashPlanner;
|
|
3580
|
+
projectGraphRef: ExternalObject<NativeProjectGraph>;
|
|
3179
3581
|
diff --git a/dist/src/hasher/native-task-hasher-impl.js b/dist/src/hasher/native-task-hasher-impl.js
|
|
3180
|
-
index 5812bc2b6c931a98193985115a15d3050e2d1020..
|
|
3582
|
+
index 5812bc2b6c931a98193985115a15d3050e2d1020..af2205ff9a7ff94d490012ceb4c49878ee1faac3 100644
|
|
3181
3583
|
--- a/dist/src/hasher/native-task-hasher-impl.js
|
|
3182
3584
|
+++ b/dist/src/hasher/native-task-hasher-impl.js
|
|
3183
|
-
@@ -
|
|
3585
|
+
@@ -10,6 +10,7 @@ const overrides_1 = require("../ultracache/overrides");
|
|
3586
|
+
class NativeTaskHasherImpl {
|
|
3587
|
+
constructor(workspaceRoot, nxJson, projectGraph, externals, options, planningContext) {
|
|
3588
|
+
this.projectGraph = projectGraph;
|
|
3589
|
+
+ this.nxJson = nxJson;
|
|
3590
|
+
/**
|
|
3591
|
+
* Plans of the last up-front batch and the task graph they were built for.
|
|
3592
|
+
* The tasks that batch deferred hash from them later without planning again.
|
|
3593
|
+
@@ -50,12 +51,13 @@ class NativeTaskHasherImpl {
|
|
3184
3594
|
unplanned.some((id) => this.upfrontPlans.taskIds.has(id)) &&
|
|
3185
3595
|
this.upfrontPlans.fingerprint ===
|
|
3186
3596
|
taskGraphFingerprint(taskGraph, ultracacheConfigurations)) {
|
|
3187
3597
|
- Object.assign(hashes, this.hasher.hashPlansFor(this.upfrontPlans.plans, unplanned, envs, resolvedCwd, shouldCollectInputs));
|
|
3188
3598
|
+ const { plans } = this.upfrontPlans;
|
|
3189
|
-
+ Object.assign(hashes, keyOwnTargetConfiguration(nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlansFor(plans, unplanned, envs, resolvedCwd, shouldCollectInputs)), taskGraph, this.projectGraph));
|
|
3599
|
+
+ Object.assign(hashes, keyOwnTargetConfiguration(nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlansFor(plans, unplanned, envs, resolvedCwd, shouldCollectInputs)), taskGraph, this.projectGraph, this.nxJson));
|
|
3190
3600
|
unplanned = unplanned.filter((id) => !(id in hashes));
|
|
3191
3601
|
}
|
|
3192
3602
|
if (unplanned.length > 0) {
|
|
3193
3603
|
const plans = this.plan(unplanned, taskGraph, ultracacheConfigurations);
|
|
3194
3604
|
- Object.assign(hashes, this.hasher.hashPlans(plans, envs, resolvedCwd, shouldCollectInputs));
|
|
3195
|
-
+ Object.assign(hashes, keyOwnTargetConfiguration(nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlans(plans, envs, resolvedCwd, shouldCollectInputs)), taskGraph, this.projectGraph));
|
|
3605
|
+
+ Object.assign(hashes, keyOwnTargetConfiguration(nameHashFailure(unplanned, this.planner, taskGraph, () => this.hasher.hashPlans(plans, envs, resolvedCwd, shouldCollectInputs)), taskGraph, this.projectGraph, this.nxJson));
|
|
3196
3606
|
}
|
|
3197
3607
|
return tasks.map((t) => hashes[t.id]);
|
|
3198
3608
|
}
|
|
3199
|
-
@@ -71,14 +
|
|
3609
|
+
@@ -71,14 +73,15 @@ class NativeTaskHasherImpl {
|
|
3200
3610
|
return this.planner.getPlansReference(taskIds, taskGraph, ultracacheConfigurations, (0, overrides_1.ultracacheEligibilityOptions)(this.projectGraph, taskGraph));
|
|
3201
3611
|
}
|
|
3202
3612
|
async hashTasksUpfront(tasks, taskGraph, perTaskEnvs, cwd, collectInputs, ultracacheConfigurations) {
|
|
@@ -3211,11 +3621,11 @@ index 5812bc2b6c931a98193985115a15d3050e2d1020..ec4f0a1b2428936062ce2beb146ac92f
|
|
|
3211
3621
|
};
|
|
3212
3622
|
const shouldCollectInputs = collectInputs ?? (0, task_io_service_1.getTaskIOService)().hasTaskInputSubscribers();
|
|
3213
3623
|
- return this.hasher.hashPlansUpfront(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs);
|
|
3214
|
-
+ return keyOwnTargetConfiguration(nameHashFailure(taskIds, this.planner, taskGraph, () => this.hasher.hashPlansUpfront(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs)), taskGraph, this.projectGraph);
|
|
3624
|
+
+ return keyOwnTargetConfiguration(nameHashFailure(taskIds, this.planner, taskGraph, () => this.hasher.hashPlansUpfront(plans, perTaskEnvs, cwd ?? process.cwd(), shouldCollectInputs)), taskGraph, this.projectGraph, this.nxJson);
|
|
3215
3625
|
}
|
|
3216
3626
|
}
|
|
3217
3627
|
exports.NativeTaskHasherImpl = NativeTaskHasherImpl;
|
|
3218
|
-
@@ -104,3 +
|
|
3628
|
+
@@ -104,3 +107,202 @@ function taskGraphFingerprint(taskGraph, ultracacheConfigurations) {
|
|
3219
3629
|
}
|
|
3220
3630
|
return (0, native_1.hashArray)(parts);
|
|
3221
3631
|
}
|
|
@@ -3226,20 +3636,26 @@ index 5812bc2b6c931a98193985115a15d3050e2d1020..ec4f0a1b2428936062ce2beb146ac92f
|
|
|
3226
3636
|
+ * of a project, so an edit to one target re-keyed every task of that project
|
|
3227
3637
|
+ * and every task whose `^` inputs reach it. A task's key holds the
|
|
3228
3638
|
+ * configuration it runs: the node of the task's own project hashes the
|
|
3229
|
-
+ * project's root, tags and
|
|
3230
|
-
+ * a project its `^` inputs reach hashes that
|
|
3231
|
-
+ *
|
|
3232
|
-
+ *
|
|
3639
|
+
+ * project's root, tags and the task's own target, and the named inputs its
|
|
3640
|
+
+ * `inputs` reach; the node of a project its `^` inputs reach hashes that
|
|
3641
|
+
+ * project's root, tags and the same named inputs. A named input is reached when
|
|
3642
|
+
+ * an input of the task names it, directly, as `^name` or as `{ input }`, or
|
|
3643
|
+
+ * when a reached named input (in nx.json or in any project) names it in turn, so
|
|
3644
|
+
+ * a named input no input of the task reaches moves no key of it: adding one to a
|
|
3645
|
+
+ * project re-keyed every task of that project, including a source build that reads
|
|
3646
|
+
+ * none. A task that declares no `inputs` keys every named input of its project.
|
|
3647
|
+
+ * The task's value folds its details again, their values in key order, as the
|
|
3648
|
+
+ * native hasher does.
|
|
3233
3649
|
+ * Upstream: https://github.com/nrwl/nx/issues/37802 and the pull request that
|
|
3234
3650
|
+ * fixes it; drop this once the installed Nx keys a task's own target only.
|
|
3235
3651
|
+ */
|
|
3236
|
-
+function keyOwnTargetConfiguration(hashes, taskGraph, projectGraph) {
|
|
3652
|
+
+function keyOwnTargetConfiguration(hashes, taskGraph, projectGraph, nxJson) {
|
|
3237
3653
|
+ const configurations = new Map();
|
|
3238
|
-
+ const configuration = (project, target) => {
|
|
3239
|
-
+ const id = JSON.stringify([project, target]);
|
|
3654
|
+
+ const configuration = (project, target, reached) => {
|
|
3655
|
+
+ const id = JSON.stringify([project, target, reached === null ? null : [...reached].sort()]);
|
|
3240
3656
|
+ let hashed = configurations.get(id);
|
|
3241
3657
|
+ if (hashed === undefined) {
|
|
3242
|
-
+ hashed = projectConfigurationHash(projectGraph, project, target);
|
|
3658
|
+
+ hashed = projectConfigurationHash(projectGraph, project, target, reached);
|
|
3243
3659
|
+ configurations.set(id, hashed);
|
|
3244
3660
|
+ }
|
|
3245
3661
|
+ return hashed;
|
|
@@ -3257,7 +3673,7 @@ index 5812bc2b6c931a98193985115a15d3050e2d1020..ec4f0a1b2428936062ce2beb146ac92f
|
|
|
3257
3673
|
+ continue;
|
|
3258
3674
|
+ }
|
|
3259
3675
|
+ const project = key.slice(0, -PROJECT_CONFIGURATION.length);
|
|
3260
|
-
+ details[key] = configuration(project, project === task.target.project ? task.target.target : null);
|
|
3676
|
+
+ details[key] = configuration(project, project === task.target.project ? task.target.target : null, reachedNamedInputs(task, projectGraph, nxJson));
|
|
3261
3677
|
+ }
|
|
3262
3678
|
+ hashes[taskId] = {
|
|
3263
3679
|
+ ...hashed,
|
|
@@ -3267,8 +3683,11 @@ index 5812bc2b6c931a98193985115a15d3050e2d1020..ec4f0a1b2428936062ce2beb146ac92f
|
|
|
3267
3683
|
+ }
|
|
3268
3684
|
+ return hashes;
|
|
3269
3685
|
+}
|
|
3270
|
-
+/**
|
|
3271
|
-
+
|
|
3686
|
+
+/**
|
|
3687
|
+
+ * A project's root, tags and the named inputs in `reached` (every one when it is null), and `target`'s executor,
|
|
3688
|
+
+ * outputs, options, configurations and parallelism.
|
|
3689
|
+
+ */
|
|
3690
|
+
+function projectConfigurationHash(projectGraph, project, target, reached) {
|
|
3272
3691
|
+ const node = projectGraph.nodes[project];
|
|
3273
3692
|
+ if (node === undefined) {
|
|
3274
3693
|
+ throw new Error(`Could not find project '${project}'`);
|
|
@@ -3290,10 +3709,68 @@ index 5812bc2b6c931a98193985115a15d3050e2d1020..ec4f0a1b2428936062ce2beb146ac92f
|
|
|
3290
3709
|
+ ];
|
|
3291
3710
|
+ }
|
|
3292
3711
|
+ const inputs = Object.keys(namedInputs ?? {})
|
|
3712
|
+
+ .filter((name) => reached === null || reached.has(name))
|
|
3293
3713
|
+ .sort()
|
|
3294
3714
|
+ .map((name) => [name, namedInputs[name]]);
|
|
3295
3715
|
+ return (0, native_1.hashArray)([JSON.stringify([root, tags ?? [], inputs, own])]);
|
|
3296
3716
|
+}
|
|
3717
|
+
+/** What an input entry can name: a string that is not a file set, a glob or a negation, or an `{ input }` object. */
|
|
3718
|
+
+const NAMED_INPUT = /^[A-Za-z_][\w.-]*$/;
|
|
3719
|
+
+function namedInputsOf(entry) {
|
|
3720
|
+
+ if (typeof entry === 'string') {
|
|
3721
|
+
+ const name = entry.startsWith('^') ? entry.slice(1) : entry;
|
|
3722
|
+
+ return NAMED_INPUT.test(name) ? [name] : [];
|
|
3723
|
+
+ }
|
|
3724
|
+
+ return typeof entry?.input === 'string' ? [entry.input] : [];
|
|
3725
|
+
+}
|
|
3726
|
+
+/** Which named input names which, over nx.json and every project: a name's references are the union of its definitions. */
|
|
3727
|
+
+const namedInputReferences = new WeakMap();
|
|
3728
|
+
+function referencesOf(projectGraph, nxJson) {
|
|
3729
|
+
+ const known = namedInputReferences.get(projectGraph);
|
|
3730
|
+
+ if (known !== undefined && known.nxJson === nxJson) {
|
|
3731
|
+
+ return known.references;
|
|
3732
|
+
+ }
|
|
3733
|
+
+ const references = new Map();
|
|
3734
|
+
+ const add = (definitions) => {
|
|
3735
|
+
+ for (const [name, entries] of Object.entries(definitions ?? {})) {
|
|
3736
|
+
+ const named = references.get(name) ?? new Set();
|
|
3737
|
+
+ for (const entry of Array.isArray(entries) ? entries : []) {
|
|
3738
|
+
+ for (const reference of namedInputsOf(entry)) {
|
|
3739
|
+
+ named.add(reference);
|
|
3740
|
+
+ }
|
|
3741
|
+
+ }
|
|
3742
|
+
+ references.set(name, named);
|
|
3743
|
+
+ }
|
|
3744
|
+
+ };
|
|
3745
|
+
+ add(nxJson?.namedInputs);
|
|
3746
|
+
+ for (const node of Object.values(projectGraph.nodes)) {
|
|
3747
|
+
+ add(node.data.namedInputs);
|
|
3748
|
+
+ }
|
|
3749
|
+
+ namedInputReferences.set(projectGraph, { nxJson, references });
|
|
3750
|
+
+ return references;
|
|
3751
|
+
+}
|
|
3752
|
+
+/**
|
|
3753
|
+
+ * The named inputs a task's inputs reach, or null when it declares none to follow: no `inputs` (the planner then
|
|
3754
|
+
+ * uses its project's defaults) or an unexpanded `...`.
|
|
3755
|
+
+ */
|
|
3756
|
+
+function reachedNamedInputs(task, projectGraph, nxJson) {
|
|
3757
|
+
+ const inputs = projectGraph.nodes[task.target.project]?.data.targets?.[task.target.target]?.inputs;
|
|
3758
|
+
+ if (!Array.isArray(inputs) || inputs.includes('...')) {
|
|
3759
|
+
+ return null;
|
|
3760
|
+
+ }
|
|
3761
|
+
+ const references = referencesOf(projectGraph, nxJson);
|
|
3762
|
+
+ const reached = new Set();
|
|
3763
|
+
+ const pending = inputs.flatMap(namedInputsOf);
|
|
3764
|
+
+ while (pending.length > 0) {
|
|
3765
|
+
+ const name = pending.pop();
|
|
3766
|
+
+ if (reached.has(name)) {
|
|
3767
|
+
+ continue;
|
|
3768
|
+
+ }
|
|
3769
|
+
+ reached.add(name);
|
|
3770
|
+
+ pending.push(...(references.get(name) ?? []));
|
|
3771
|
+
+ }
|
|
3772
|
+
+ return reached;
|
|
3773
|
+
+}
|
|
3297
3774
|
+/** A refusal names this many task ids and counts the rest, as cowshed's refusals do. */
|
|
3298
3775
|
+const NAMED_TASKS = 10;
|
|
3299
3776
|
+function namedTasks(ids) {
|
|
@@ -3416,19 +3893,83 @@ index 6fa8fdb04f096837631b21a25893a714848ea922..37f16e888262892b51392c76f5d0ecea
|
|
|
3416
3893
|
}
|
|
3417
3894
|
async hashTask(task, taskGraph, env) {
|
|
3418
3895
|
return (await this.hashTasks([task], taskGraph, {
|
|
3896
|
+
diff --git a/dist/src/plugins/js/index.js b/dist/src/plugins/js/index.js
|
|
3897
|
+
index 8190f2152e5dd4beb64de47758e4b6a351511758..8cd064c681e4cde87579da4fe59c353d6439265b 100644
|
|
3898
|
+
--- a/dist/src/plugins/js/index.js
|
|
3899
|
+
+++ b/dist/src/plugins/js/index.js
|
|
3900
|
+
@@ -47,21 +47,29 @@ function internalCreateNodes(lockFile, _, context) {
|
|
3901
|
+
: (0, bun_parser_1.readBunLockFile)(lockFilePath);
|
|
3902
|
+
const lockFileHash = getLockFileHash(lockFileContents);
|
|
3903
|
+
cachedLockFile = { packageManager, lockFile, lockFileContents, lockFileHash };
|
|
3904
|
+
+ const isBunTextLock = lockFile === bun_parser_1.BUN_TEXT_LOCK_FILE;
|
|
3905
|
+
const cached = readCache(externalNodesCache, lockFileHash);
|
|
3906
|
+
+ let nodes;
|
|
3907
|
+
if (cached) {
|
|
3908
|
+
- cachedKeyMap = deserializeKeyMap(cached.keyMap, cached.nodes);
|
|
3909
|
+
- return {
|
|
3910
|
+
- externalNodes: cached.nodes,
|
|
3911
|
+
- };
|
|
3912
|
+
+ nodes = cached.nodes;
|
|
3913
|
+
+ cachedKeyMap = deserializeKeyMap(cached.keyMap, nodes);
|
|
3914
|
+
+ }
|
|
3915
|
+
+ else {
|
|
3916
|
+
+ // The persistent cache is a function of lock text, never live patch bytes.
|
|
3917
|
+
+ const parsed = isBunTextLock
|
|
3918
|
+
+ ? (0, lock_file_1.getLockFileNodesForName)(lockFile, lockFileContents, lockFileHash)
|
|
3919
|
+
+ : (0, lock_file_1.getLockFileNodes)(packageManager, lockFile, lockFileContents, lockFileHash, context);
|
|
3920
|
+
+ nodes = parsed.nodes;
|
|
3921
|
+
+ cachedKeyMap = parsed.keyMap;
|
|
3922
|
+
+ writeCache(externalNodesCache, lockFileHash, {
|
|
3923
|
+
+ nodes,
|
|
3924
|
+
+ keyMap: serializeKeyMap(cachedKeyMap),
|
|
3925
|
+
+ });
|
|
3926
|
+
}
|
|
3927
|
+
- const { nodes: externalNodes, keyMap } = (0, lock_file_1.getLockFileNodes)(packageManager, lockFile, lockFileContents, lockFileHash, context);
|
|
3928
|
+
- cachedKeyMap = keyMap;
|
|
3929
|
+
- writeCache(externalNodesCache, lockFileHash, {
|
|
3930
|
+
- nodes: externalNodes,
|
|
3931
|
+
- keyMap: serializeKeyMap(keyMap),
|
|
3932
|
+
- });
|
|
3933
|
+
return {
|
|
3934
|
+
- externalNodes,
|
|
3935
|
+
+ externalNodes: isBunTextLock
|
|
3936
|
+
+ ? (0, bun_parser_1.applyBunPatchHashes)(nodes, lockFileContents, lockFileHash, context.workspaceRoot)
|
|
3937
|
+
+ : nodes,
|
|
3938
|
+
};
|
|
3939
|
+
}
|
|
3940
|
+
const createDependencies = (_, ctx) => {
|
|
3419
3941
|
diff --git a/dist/src/plugins/js/lock-file/bun-parser.js b/dist/src/plugins/js/lock-file/bun-parser.js
|
|
3420
|
-
index 169563d598af64c8b74d00ab9815dd651650ec9d..
|
|
3942
|
+
index 169563d598af64c8b74d00ab9815dd651650ec9d..20649f44c57701a6b7aa8e3a6a8438b9949e07f9 100644
|
|
3421
3943
|
--- a/dist/src/plugins/js/lock-file/bun-parser.js
|
|
3422
3944
|
+++ b/dist/src/plugins/js/lock-file/bun-parser.js
|
|
3423
|
-
@@ -
|
|
3945
|
+
@@ -5,8 +5,10 @@ exports.readBunLockFile = readBunLockFile;
|
|
3946
|
+
exports.getBunTextLockfileDependencies = getBunTextLockfileDependencies;
|
|
3947
|
+
exports.clearCache = clearCache;
|
|
3424
3948
|
exports.getBunTextLockfileNodes = getBunTextLockfileNodes;
|
|
3949
|
+
+exports.applyBunPatchHashes = applyBunPatchHashes;
|
|
3425
3950
|
const node_child_process_1 = require("node:child_process");
|
|
3426
3951
|
const node_fs_1 = require("node:fs");
|
|
3427
3952
|
+const node_path_1 = require("node:path");
|
|
3428
3953
|
const semver_1 = require("semver");
|
|
3429
3954
|
const project_graph_1 = require("../../../config/project-graph");
|
|
3430
3955
|
const file_hasher_1 = require("../../../hasher/file-hasher");
|
|
3431
|
-
@@ -
|
|
3956
|
+
@@ -33,6 +35,7 @@ exports.BUN_TEXT_LOCK_FILE = 'bun.lock';
|
|
3957
|
+
let currentLockFileHash;
|
|
3958
|
+
let cachedParsedLockFile;
|
|
3959
|
+
let cachedPackageIndex;
|
|
3960
|
+
+let cachedExternalNodes;
|
|
3961
|
+
const keyMap = new Map();
|
|
3962
|
+
const packageVersions = new Map();
|
|
3963
|
+
const specParseCache = new Map();
|
|
3964
|
+
@@ -83,6 +86,7 @@ function clearCache() {
|
|
3965
|
+
currentLockFileHash = undefined;
|
|
3966
|
+
cachedParsedLockFile = undefined;
|
|
3967
|
+
cachedPackageIndex = undefined;
|
|
3968
|
+
+ cachedExternalNodes = undefined;
|
|
3969
|
+
keyMap.clear();
|
|
3970
|
+
packageVersions.clear();
|
|
3971
|
+
specParseCache.clear();
|
|
3972
|
+
@@ -285,8 +289,7 @@ function buildPackageIndex(lockFile) {
|
|
3432
3973
|
...workspace.peerDependencies,
|
|
3433
3974
|
};
|
|
3434
3975
|
for (const [depName, depVersion] of Object.entries(allDeps)) {
|
|
@@ -3438,7 +3979,7 @@ index 169563d598af64c8b74d00ab9815dd651650ec9d..0bd5e1f536b1e0e02843396e01b29dce
|
|
|
3438
3979
|
workspaceNames.add(depName);
|
|
3439
3980
|
}
|
|
3440
3981
|
}
|
|
3441
|
-
@@ -306,8 +
|
|
3982
|
+
@@ -306,8 +309,9 @@ function buildPackageIndex(lockFile) {
|
|
3442
3983
|
if (!name || !version) {
|
|
3443
3984
|
continue;
|
|
3444
3985
|
}
|
|
@@ -3450,6 +3991,110 @@ index 169563d598af64c8b74d00ab9815dd651650ec9d..0bd5e1f536b1e0e02843396e01b29dce
|
|
|
3450
3991
|
workspaceNames.add(name);
|
|
3451
3992
|
}
|
|
3452
3993
|
// Check if this is a workspace-specific variant (e.g., "@quz/pkg1/lodash")
|
|
3994
|
+
@@ -384,6 +388,10 @@ function parseLockFile(lockFileContent, lockFileHash) {
|
|
3995
|
+
if (result.patches && typeof result.patches !== 'object') {
|
|
3996
|
+
throw new Error('Lockfile patches section must be an object');
|
|
3997
|
+
}
|
|
3998
|
+
+ if (result.patchedDependencies !== undefined &&
|
|
3999
|
+
+ (!result.patchedDependencies || typeof result.patchedDependencies !== 'object' || Array.isArray(result.patchedDependencies))) {
|
|
4000
|
+
+ throw new Error('Lockfile patchedDependencies must map package versions to patch paths');
|
|
4001
|
+
+ }
|
|
4002
|
+
if (result.manifests && typeof result.manifests !== 'object') {
|
|
4003
|
+
throw new Error('Lockfile manifests section must be an object');
|
|
4004
|
+
}
|
|
4005
|
+
@@ -440,10 +448,11 @@ function parseLockFile(lockFileContent, lockFileHash) {
|
|
4006
|
+
function getBunTextLockfileNodes(lockFileContent, lockFileHash) {
|
|
4007
|
+
try {
|
|
4008
|
+
const { lockFile, index } = parseLockFile(lockFileContent, lockFileHash);
|
|
4009
|
+
+ if (cachedExternalNodes) return cachedExternalNodes;
|
|
4010
|
+
const nodes = {};
|
|
4011
|
+
const localPackageVersions = new Map();
|
|
4012
|
+
if (!lockFile.packages || Object.keys(lockFile.packages).length === 0) {
|
|
4013
|
+
- return nodes;
|
|
4014
|
+
+ return (cachedExternalNodes = nodes);
|
|
4015
|
+
}
|
|
4016
|
+
const packageEntries = Object.entries(lockFile.packages);
|
|
4017
|
+
for (const [packageKey, packageData] of packageEntries) {
|
|
4018
|
+
@@ -453,7 +462,7 @@ function getBunTextLockfileNodes(lockFileContent, lockFileHash) {
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
createHoistedNodes(localPackageVersions, lockFile, index, keyMap, nodes);
|
|
4022
|
+
- return nodes;
|
|
4023
|
+
+ return (cachedExternalNodes = nodes);
|
|
4024
|
+
}
|
|
4025
|
+
catch (error) {
|
|
4026
|
+
if (error instanceof Error) {
|
|
4027
|
+
@@ -462,6 +471,50 @@ function getBunTextLockfileNodes(lockFileContent, lockFileHash) {
|
|
4028
|
+
throw new Error(`Failed to get Bun lockfile nodes: ${error.message}`);
|
|
4029
|
+
}
|
|
4030
|
+
}
|
|
4031
|
+
+/** Apply live patch bytes after loading the lock-only nodes, including on a cache hit. */
|
|
4032
|
+
+/** Apply live patch bytes after loading the lock-only nodes, including on a cache hit. */
|
|
4033
|
+
+function applyBunPatchHashes(nodes, lockFileContent, lockFileHash, workspaceRoot) {
|
|
4034
|
+
+ const { lockFile, index } = parseLockFile(lockFileContent, lockFileHash);
|
|
4035
|
+
+ const patches = lockFile.patchedDependencies;
|
|
4036
|
+
+ if (!patches) return nodes;
|
|
4037
|
+
+ let result = nodes;
|
|
4038
|
+
+ const byPath = new Map();
|
|
4039
|
+
+ for (const [identity, path] of Object.entries(patches)) {
|
|
4040
|
+
+ const versioned = nodes[`npm:${identity}`];
|
|
4041
|
+
+ if (!versioned) continue;
|
|
4042
|
+
+ const { packageName, version } = versioned.data;
|
|
4043
|
+
+ if (typeof path !== 'string' || path.length === 0) {
|
|
4044
|
+
+ throw new Error(`Invalid Bun patch path for ${identity}: expected a non-empty path`);
|
|
4045
|
+
+ }
|
|
4046
|
+
+ let patchHash = byPath.get(path);
|
|
4047
|
+
+ if (patchHash === undefined) {
|
|
4048
|
+
+ try {
|
|
4049
|
+
+ patchHash = (0, file_hasher_1.hashFile)((0, node_path_1.resolve)(workspaceRoot, path));
|
|
4050
|
+
+ if (patchHash == null) throw new Error('could not read its bytes');
|
|
4051
|
+
+ }
|
|
4052
|
+
+ catch (error) {
|
|
4053
|
+
+ throw new Error(`Cannot hash Bun patch ${path} for ${identity}: ${error.message}`, { cause: error });
|
|
4054
|
+
+ }
|
|
4055
|
+
+ byPath.set(path, patchHash);
|
|
4056
|
+
+ }
|
|
4057
|
+
+ if (result === nodes) result = { ...nodes };
|
|
4058
|
+
+ const withPatch = (node) => ({
|
|
4059
|
+
+ ...node,
|
|
4060
|
+
+ data: { ...node.data, hash: (0, file_hasher_1.hashArray)([node.data.hash, patchHash]) },
|
|
4061
|
+
+ });
|
|
4062
|
+
+ result[versioned.name] = withPatch(versioned);
|
|
4063
|
+
+ const hoisted = nodes[`npm:${packageName}`];
|
|
4064
|
+
+ if (hoisted?.data.version === version) {
|
|
4065
|
+
+ result[hoisted.name] = { ...hoisted, data: { ...hoisted.data, hash: result[versioned.name].data.hash } };
|
|
4066
|
+
+ }
|
|
4067
|
+
+ for (const entry of index.byName.get(packageName) ?? []) {
|
|
4068
|
+
+ if (entry.version !== version || entry.packageKey === packageName) continue;
|
|
4069
|
+
+ const alias = nodes[`npm:${entry.packageKey}`];
|
|
4070
|
+
+ if (alias?.data.version === `npm:${identity}`) result[alias.name] = withPatch(alias);
|
|
4071
|
+
+ }
|
|
4072
|
+
+ }
|
|
4073
|
+
+ return result;
|
|
4074
|
+
+}
|
|
4075
|
+
function processPackageEntry(packageKey, packageData, lockFile, index, keyMap, nodes, packageVersions) {
|
|
4076
|
+
try {
|
|
4077
|
+
if (!Array.isArray(packageData) ||
|
|
4078
|
+
diff --git a/dist/src/plugins/js/lock-file/lock-file.js b/dist/src/plugins/js/lock-file/lock-file.js
|
|
4079
|
+
index e9bc3673ce7e3ecb71e74c26633d88a4e6d9aa67..7810678810f73a20b15333c1481c653b98178e40 100644
|
|
4080
|
+
--- a/dist/src/plugins/js/lock-file/lock-file.js
|
|
4081
|
+
+++ b/dist/src/plugins/js/lock-file/lock-file.js
|
|
4082
|
+
@@ -58,7 +58,14 @@ const BUN_TEXT_LOCK_PATH = (0, node_path_1.join)(workspace_root_1.workspaceRoot,
|
|
4083
|
+
*/
|
|
4084
|
+
function getLockFileNodes(packageManager, lockFile, contents, lockFileHash, context) {
|
|
4085
|
+
try {
|
|
4086
|
+
- const packageJson = packageManager === 'yarn' || packageManager === 'bun'
|
|
4087
|
+
+ if (lockFile === bun_parser_1.BUN_TEXT_LOCK_FILE) {
|
|
4088
|
+
+ const nodes = (0, bun_parser_1.getBunTextLockfileNodes)(contents, lockFileHash);
|
|
4089
|
+
+ return {
|
|
4090
|
+
+ nodes: (0, bun_parser_1.applyBunPatchHashes)(nodes, contents, lockFileHash, context.workspaceRoot),
|
|
4091
|
+
+ keyMap: new Map(),
|
|
4092
|
+
+ };
|
|
4093
|
+
+ }
|
|
4094
|
+
+ const packageJson = packageManager === 'yarn' || lockFile === bun_parser_1.BUN_LOCK_FILE
|
|
4095
|
+
? (0, fileutils_1.readJsonFile)((0, node_path_1.join)(context.workspaceRoot, 'package.json'))
|
|
4096
|
+
: undefined;
|
|
4097
|
+
return getLockFileNodesForName(lockFile, contents, lockFileHash, packageJson);
|
|
3453
4098
|
diff --git a/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js b/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js
|
|
3454
4099
|
index 5c2bcfaa11caef956fc906f2693586cb647b1382..1eeccd1ba61ce8391596f06aafeb0452cb49cf2a 100644
|
|
3455
4100
|
--- a/dist/src/plugins/js/project-graph/build-dependencies/target-project-locator.js
|
|
@@ -3736,7 +4381,7 @@ index 93f05fdfa622883efbb45dba383fd419938a605c..34ec5d92356d4262c233dfbef88804a0
|
|
|
3736
4381
|
* Returns specified plugins (from nx.json) and default plugins (project.json,
|
|
3737
4382
|
* package.json, etc.) as separate arrays. This separation is needed for
|
|
3738
4383
|
diff --git a/dist/src/project-graph/plugins/get-plugins.js b/dist/src/project-graph/plugins/get-plugins.js
|
|
3739
|
-
index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..
|
|
4384
|
+
index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..109b9d9a2fe169ea8a70314dca68dddda3152a6b 100644
|
|
3740
4385
|
--- a/dist/src/project-graph/plugins/get-plugins.js
|
|
3741
4386
|
+++ b/dist/src/project-graph/plugins/get-plugins.js
|
|
3742
4387
|
@@ -4,6 +4,7 @@ exports.loadingMethod = void 0;
|
|
@@ -3757,13 +4402,15 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3757
4402
|
/**
|
|
3758
4403
|
* Stuff for specified NX Plugins.
|
|
3759
4404
|
*/
|
|
3760
|
-
@@ -65,11 +69,
|
|
4405
|
+
@@ -65,11 +69,13 @@ function resetIsolationFallbackForTesting() {
|
|
3761
4406
|
isolationRefusedInThisProcess = false;
|
|
3762
4407
|
}
|
|
3763
4408
|
/**
|
|
3764
4409
|
- * Loads a plugin in a worker, falling back to this process when the worker's
|
|
3765
4410
|
- * socket was refused.
|
|
3766
|
-
+ * Loads local source
|
|
4411
|
+
+ * Loads local source where a change to it can take effect: in restartable
|
|
4412
|
+
+ * workers, or, in a daemon with isolation off, in the daemon's own process,
|
|
4413
|
+
+ * which restarts when a file it loaded changes. Installed plugins follow the
|
|
3767
4414
|
+ * isolation setting and may fall back to this process on worker socket refusal.
|
|
3768
4415
|
*
|
|
3769
4416
|
- * Isolation is preferred: it is what keeps two plugins with conflicting
|
|
@@ -3773,7 +4420,7 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3773
4420
|
* been told about the Nx socket root refuses the worker's socket, and failing
|
|
3774
4421
|
* the whole command over that is worse than running the plugins here. The
|
|
3775
4422
|
* fallback is narrow on purpose. It needs a failure to start or reach the
|
|
3776
|
-
@@ -80,15 +
|
|
4423
|
+
@@ -80,15 +86,34 @@ function resetIsolationFallbackForTesting() {
|
|
3777
4424
|
* error.
|
|
3778
4425
|
*/
|
|
3779
4426
|
const loadingMethod = async (plugin, root, index) => {
|
|
@@ -3787,11 +4434,15 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3787
4434
|
+ throw new error_types_1.LoadPluginError(moduleName, error);
|
|
3788
4435
|
+ }
|
|
3789
4436
|
+ const local = (0, local_plugin_source_1.localPluginPath)(root, resolved.pluginPath) !== null;
|
|
3790
|
-
+ // ESM modules cannot be evicted in-process. Local source therefore needs a
|
|
3791
|
-
+ // restartable worker even when installed plugins run in this process.
|
|
3792
4437
|
+ if (!local && (!(0, enabled_1.isIsolationEnabled)() || isolationRefusedInThisProcess)) {
|
|
3793
4438
|
return (0, in_process_loader_1.loadNxPlugin)(plugin, root, index);
|
|
3794
4439
|
}
|
|
4440
|
+
+ // ESM modules cannot be evicted in-process. A daemon with isolation off
|
|
4441
|
+
+ // holds local source itself and restarts when it changes; every other
|
|
4442
|
+
+ // process needs a restartable worker.
|
|
4443
|
+
+ if (local && !(0, enabled_1.isIsolationEnabled)() && (0, local_plugin_source_1.canHoldLocalPlugins)()) {
|
|
4444
|
+
+ return (0, local_plugin_source_1.holdLocalPlugin)(root, () => (0, in_process_loader_1.loadNxPlugin)(plugin, root, index), () => require('../../daemon/server/restart-checks').restartDaemonForLocalPlugins());
|
|
4445
|
+
+ }
|
|
3795
4446
|
// Awaited here rather than handed on, because the worker failure surfaces on
|
|
3796
4447
|
// this promise and the fallback has to happen before the caller sees it.
|
|
3797
4448
|
try {
|
|
@@ -3799,14 +4450,14 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3799
4450
|
+ return await (0, isolation_1.loadIsolatedNxPlugin)(plugin, root, index, resolved);
|
|
3800
4451
|
}
|
|
3801
4452
|
catch (e) {
|
|
3802
|
-
+ // A local plugin
|
|
4453
|
+
+ // A local plugin's worker is its reload, so it has no fallback.
|
|
3803
4454
|
+ if (local) {
|
|
3804
4455
|
+ throw e;
|
|
3805
4456
|
+ }
|
|
3806
4457
|
// Proof, kept separate from policy. The errno the worker saw is what makes
|
|
3807
4458
|
// the message certain; whether that errno is also grounds for degrading is a
|
|
3808
4459
|
// different question, and conflating them made the warning assert a sandbox
|
|
3809
|
-
@@ -127,6 +
|
|
4460
|
+
@@ -127,6 +152,13 @@ const loadingMethod = async (plugin, root, index) => {
|
|
3810
4461
|
}
|
|
3811
4462
|
};
|
|
3812
4463
|
exports.loadingMethod = loadingMethod;
|
|
@@ -3820,7 +4471,7 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3820
4471
|
/**
|
|
3821
4472
|
* Returns all plugins (specified + default) as a flat list.
|
|
3822
4473
|
* Specified plugins come first, followed by default plugins.
|
|
3823
|
-
@@ -147,8 +
|
|
4474
|
+
@@ -147,8 +179,8 @@ async function getPlugins(nxJson, root = workspace_root_1.workspaceRoot) {
|
|
3824
4475
|
*/
|
|
3825
4476
|
async function getPluginsSeparated(nxJson, root = workspace_root_1.workspaceRoot) {
|
|
3826
4477
|
const pluginsConfiguration = nxJson.plugins ?? [];
|
|
@@ -3831,7 +4482,7 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3831
4482
|
if (cachedSeparatedPlugins &&
|
|
3832
4483
|
pluginsConfigurationHash === currentPluginsConfigurationHash) {
|
|
3833
4484
|
return cachedSeparatedPlugins;
|
|
3834
|
-
@@ -281,7 +
|
|
4485
|
+
@@ -281,7 +313,9 @@ async function loadPlugins(loader, pluginConfigurations, root, assignIndexes) {
|
|
3835
4486
|
}
|
|
3836
4487
|
async function capabilitiesOfConfiguredPlugins(nxJson, root = workspace_root_1.workspaceRoot) {
|
|
3837
4488
|
if (!(0, is_on_daemon_1.isOnDaemon)() && (0, client_1.isDaemonEnabled)()) {
|
|
@@ -3842,7 +4493,7 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3842
4493
|
}
|
|
3843
4494
|
const recorded = (0, nx_plugin_capabilities_1.capabilitiesOfNxPluginsReadFromCache)();
|
|
3844
4495
|
if (recorded) {
|
|
3845
|
-
@@ -311,7 +
|
|
4496
|
+
@@ -311,7 +345,7 @@ async function loadDefaultNxPlugins(root = workspace_root_1.workspaceRoot) {
|
|
3846
4497
|
// Cleared so the next call retries instead of re-awaiting this rejection.
|
|
3847
4498
|
pendingDefaultPluginPromise = undefined;
|
|
3848
4499
|
const errorMessage = errors
|
|
@@ -3851,7 +4502,7 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3851
4502
|
.join('\n');
|
|
3852
4503
|
throw new AggregateError(errors.map((e) => e.error), `Failed to load ${errors.length} default Nx plugin(s):\n${errorMessage}`);
|
|
3853
4504
|
}
|
|
3854
|
-
@@ -348,7 +
|
|
4505
|
+
@@ -348,7 +382,7 @@ async function loadSpecifiedNxPlugins(pluginsConfigurations, root = workspace_ro
|
|
3855
4506
|
if (errors.length > 0) {
|
|
3856
4507
|
// Wants are not retracted: a newer load may own the declaration by now.
|
|
3857
4508
|
const errorMessage = errors
|
|
@@ -3860,7 +4511,7 @@ index b5f180eb7c517d26c2bf8ca6377c1aeb9f69d0e7..bca08e11b1daef7a6da85b7fdd4dbca9
|
|
|
3860
4511
|
.join('\n');
|
|
3861
4512
|
throw new AggregateError(errors.map((e) => e.error), `Failed to load ${errors.length} Nx plugin(s):\n${errorMessage}`);
|
|
3862
4513
|
}
|
|
3863
|
-
@@ -363,6 +
|
|
4514
|
+
@@ -363,6 +397,12 @@ function reasonToError(reason) {
|
|
3864
4515
|
if ('stack' in reason) {
|
|
3865
4516
|
error.stack = String(reason.stack);
|
|
3866
4517
|
}
|
|
@@ -4337,10 +4988,10 @@ index 9fa6b993ac4dbe918c163092c12f77f87eaccb27..d93538310c4dc2622cde88cd9da983bc
|
|
|
4337
4988
|
target[key] = value;
|
|
4338
4989
|
diff --git a/dist/src/project-graph/plugins/local-plugin-source.d.ts b/dist/src/project-graph/plugins/local-plugin-source.d.ts
|
|
4339
4990
|
new file mode 100644
|
|
4340
|
-
index 0000000000000000000000000000000000000000..
|
|
4991
|
+
index 0000000000000000000000000000000000000000..9aaee0e0b5b3a14dacfc4ca1a618b9f1f391cc59
|
|
4341
4992
|
--- /dev/null
|
|
4342
4993
|
+++ b/dist/src/project-graph/plugins/local-plugin-source.d.ts
|
|
4343
|
-
@@ -0,0 +1,
|
|
4994
|
+
@@ -0,0 +1,26 @@
|
|
4344
4995
|
+export interface LocalPluginSourceReceipt {
|
|
4345
4996
|
+ readonly path: string;
|
|
4346
4997
|
+ readonly hash: string;
|
|
@@ -4359,16 +5010,20 @@ index 0000000000000000000000000000000000000000..1a84106509d0e05a2f0d6c595b79ecc7
|
|
|
4359
5010
|
+export declare function recordLocalPluginSources(source: LocalPluginSource | undefined, loaded: readonly LocalPluginSourceReceipt[] | undefined): void;
|
|
4360
5011
|
+export declare function invalidateLocalPluginSources(root: string, changedFiles: readonly string[]): void;
|
|
4361
5012
|
+/** The paths among `paths` that a local plugin of `root` loaded, in order. */
|
|
4362
|
-
+export declare function
|
|
5013
|
+
+export declare function invalidateLocalPluginSources(root: string, changedFiles: readonly string[]): boolean;
|
|
5014
|
+
+/** Whether this process can hold local plugins in its own module cache: a Node daemon. */
|
|
5015
|
+
+export declare function canHoldLocalPlugins(): boolean;
|
|
5016
|
+
+/** Loads a local plugin into this process; `restart` runs once when a file its closure loaded changes. */
|
|
5017
|
+
+export declare function holdLocalPlugin<T>(root: string, load: () => Promise<T>, restart: () => void): Promise<T>;
|
|
4363
5018
|
+export declare function invalidateIgnoredLocalPluginSources(root: string, changedFiles: readonly string[]): boolean;
|
|
4364
5019
|
+export declare function getLocalPluginGeneration(): number;
|
|
4365
5020
|
+export declare function trackLocalPluginLoads(root: string): () => LocalPluginSourceReceipt[];
|
|
4366
5021
|
diff --git a/dist/src/project-graph/plugins/local-plugin-source.js b/dist/src/project-graph/plugins/local-plugin-source.js
|
|
4367
5022
|
new file mode 100644
|
|
4368
|
-
index 0000000000000000000000000000000000000000..
|
|
5023
|
+
index 0000000000000000000000000000000000000000..813c7134e970f00e7003a0708cc483f55c320d33
|
|
4369
5024
|
--- /dev/null
|
|
4370
5025
|
+++ b/dist/src/project-graph/plugins/local-plugin-source.js
|
|
4371
|
-
@@ -0,0 +1,
|
|
5026
|
+
@@ -0,0 +1,209 @@
|
|
4372
5027
|
+"use strict";
|
|
4373
5028
|
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
4374
5029
|
+exports.localPluginPath = localPluginPath;
|
|
@@ -4381,12 +5036,48 @@ index 0000000000000000000000000000000000000000..acc04ca3d6da95a0992bf96df3587a78
|
|
|
4381
5036
|
+exports.localPluginSourceMembers = localPluginSourceMembers;
|
|
4382
5037
|
+exports.pluginsAffectedBySourceHashes = pluginsAffectedBySourceHashes;
|
|
4383
5038
|
+exports.trackLocalPluginLoads = trackLocalPluginLoads;
|
|
5039
|
+
+exports.canHoldLocalPlugins = canHoldLocalPlugins;
|
|
5040
|
+
+exports.holdLocalPlugin = holdLocalPlugin;
|
|
4384
5041
|
+const { createHash } = require("node:crypto");
|
|
4385
5042
|
+const { readFileSync } = require("node:fs");
|
|
4386
5043
|
+const { relative, resolve, sep, isAbsolute } = require("node:path");
|
|
4387
5044
|
+const { fileURLToPath } = require("node:url");
|
|
4388
5045
|
+const sourcesByRoot = new Map();
|
|
4389
5046
|
+let generation = 0;
|
|
5047
|
+
+// The one closure of every local plugin this process holds in its own module
|
|
5048
|
+
+// cache: a daemon with isolation off. Its loads are observed as a worker's are.
|
|
5049
|
+
+let held;
|
|
5050
|
+
+let takeHeldLoads;
|
|
5051
|
+
+// Only a daemon can answer a changed closure by restarting, and only Node
|
|
5052
|
+
+// observes module loads.
|
|
5053
|
+
+function canHoldLocalPlugins() {
|
|
5054
|
+
+ return !!global.NX_DAEMON && !process.versions.bun && typeof require('node:module').registerHooks === 'function';
|
|
5055
|
+
+}
|
|
5056
|
+
+// Loads a local plugin into this process. Its closure joins the held one, and
|
|
5057
|
+
+// `restart` runs once when a file of that closure changes. A load that failed
|
|
5058
|
+
+// may have left a module no one can evict, so the next source change restarts.
|
|
5059
|
+
+async function holdLocalPlugin(root, load, restart) {
|
|
5060
|
+
+ if (!held?.active) {
|
|
5061
|
+
+ held = createLocalPluginSource(root, restart);
|
|
5062
|
+
+ takeHeldLoads ??= trackLocalPluginLoads(resolve(root));
|
|
5063
|
+
+ }
|
|
5064
|
+
+ const source = held;
|
|
5065
|
+
+ try {
|
|
5066
|
+
+ return await load();
|
|
5067
|
+
+ }
|
|
5068
|
+
+ catch (error) {
|
|
5069
|
+
+ source.failed = true;
|
|
5070
|
+
+ throw error;
|
|
5071
|
+
+ }
|
|
5072
|
+
+ finally {
|
|
5073
|
+
+ recordHeldLoads();
|
|
5074
|
+
+ }
|
|
5075
|
+
+}
|
|
5076
|
+
+// Lazy and computed imports load after the plugin did: take what the hook saw
|
|
5077
|
+
+// before each judgment.
|
|
5078
|
+
+function recordHeldLoads() {
|
|
5079
|
+
+ if (held?.active) recordLocalPluginSources(held, takeHeldLoads());
|
|
5080
|
+
+}
|
|
4390
5081
|
+// A resolved package-manager link into workspace source is local; installed
|
|
4391
5082
|
+// packages and links into another checkout retain their installation policy.
|
|
4392
5083
|
+function localPluginPath(root, file) {
|
|
@@ -4457,15 +5148,22 @@ index 0000000000000000000000000000000000000000..acc04ca3d6da95a0992bf96df3587a78
|
|
|
4457
5148
|
+ }
|
|
4458
5149
|
+ }
|
|
4459
5150
|
+}
|
|
5151
|
+
+// True when the held closure changed: the daemon is restarting and no
|
|
5152
|
+
+// recompute follows.
|
|
4460
5153
|
+function invalidateLocalPluginSources(root, changedFiles) {
|
|
5154
|
+
+ recordHeldLoads();
|
|
4461
5155
|
+ const sources = sourcesByRoot.get(resolve(root));
|
|
4462
|
-
+ if (!sources) return;
|
|
5156
|
+
+ if (!sources) return false;
|
|
4463
5157
|
+ const affected = pluginsAffectedByChanges(sources, changedFiles);
|
|
5158
|
+
+ if (held?.active && held.failed && changedFiles.length > 0 && !affected.includes(held)) affected.push(held);
|
|
5159
|
+
+ const restarting = affected.includes(held);
|
|
4464
5160
|
+ for (const source of affected) source.invalidate();
|
|
5161
|
+
+ return restarting;
|
|
4465
5162
|
+}
|
|
4466
5163
|
+// The paths among `paths` that a local plugin of `root` loaded, in order.
|
|
4467
5164
|
+function localPluginSourceMembers(root, paths) {
|
|
4468
5165
|
+ const sources = sourcesByRoot.get(resolve(root));
|
|
5166
|
+
+ recordHeldLoads();
|
|
4469
5167
|
+ if (!sources) return [];
|
|
4470
5168
|
+ return paths.filter((path) => [...sources.keys()].some((source) => source.files.has(path)));
|
|
4471
5169
|
+}
|
|
@@ -4485,6 +5183,7 @@ index 0000000000000000000000000000000000000000..acc04ca3d6da95a0992bf96df3587a78
|
|
|
4485
5183
|
+ return affected;
|
|
4486
5184
|
+}
|
|
4487
5185
|
+function invalidateIgnoredLocalPluginSources(root, changedFiles) {
|
|
5186
|
+
+ recordHeldLoads();
|
|
4488
5187
|
+ const sources = sourcesByRoot.get(resolve(root));
|
|
4489
5188
|
+ if (!sources) return false;
|
|
4490
5189
|
+ const currentHashes = new Map();
|
|
@@ -4555,6 +5254,47 @@ index 9014799cfb98f624d9d2b04891c3c9d876c64916..e29dd0e015e0e63ccdd27c2036b0395f
|
|
|
4555
5254
|
readonly argv: string[];
|
|
4556
5255
|
};
|
|
4557
5256
|
export type PostTasksExecutionContext = {
|
|
5257
|
+
diff --git a/dist/src/project-graph/plugins/resolve-plugin.js b/dist/src/project-graph/plugins/resolve-plugin.js
|
|
5258
|
+
index 8dcf1f508bd5447f356cab4d63fedd3f24a6e383..3cf40d176ccbef975fa9794901eda3af0157ed3e 100644
|
|
5259
|
+
--- a/dist/src/project-graph/plugins/resolve-plugin.js
|
|
5260
|
+
+++ b/dist/src/project-graph/plugins/resolve-plugin.js
|
|
5261
|
+
@@ -19,6 +19,18 @@ const retrieve_workspace_files_1 = require("../utils/retrieve-workspace-files");
|
|
5262
|
+
const TS_SOURCE_EXTENSIONS = new Set(['.ts', '.tsx', '.cts', '.mts']);
|
|
5263
|
+
let projectsWithoutInference;
|
|
5264
|
+
let projectsWithoutInferencePromise = null;
|
|
5265
|
+
+/**
|
|
5266
|
+
+ * A plugin nx.json names by a relative path (`./tools/plugin.js`) is that file under the
|
|
5267
|
+
+ * workspace root, resolved as a path. Bun's resolver keeps a directory's entries for the life of
|
|
5268
|
+
+ * its process once it has looked anything up there, so a relative specifier never finds a file
|
|
5269
|
+
+ * written after that lookup, while the absolute path is read from the file system: a long-lived
|
|
5270
|
+
+ * Bun client (one Nx run after another in one process) then loaded no plugin a writer had added.
|
|
5271
|
+
+ */
|
|
5272
|
+
+function fromRoot(moduleName, root) {
|
|
5273
|
+
+ return moduleName.startsWith('./') || moduleName.startsWith('../')
|
|
5274
|
+
+ ? path.resolve(root, moduleName)
|
|
5275
|
+
+ : moduleName;
|
|
5276
|
+
+}
|
|
5277
|
+
async function resolveNxPlugin(moduleName, root, paths) {
|
|
5278
|
+
// Default plugins (see `getDefaultPlugins` in `get-plugins.ts`) are passed
|
|
5279
|
+
// as absolute file paths to compiled bundles inside `nx` itself; they are
|
|
5280
|
+
@@ -28,7 +40,7 @@ async function resolveNxPlugin(moduleName, root, paths) {
|
|
5281
|
+
if (!path.isAbsolute(moduleName)) {
|
|
5282
|
+
let resolvedFromNode;
|
|
5283
|
+
try {
|
|
5284
|
+
- resolvedFromNode = require.resolve(moduleName, { paths });
|
|
5285
|
+
+ resolvedFromNode = require.resolve(fromRoot(moduleName, root), { paths });
|
|
5286
|
+
}
|
|
5287
|
+
catch { }
|
|
5288
|
+
// Load projects if Node couldn't resolve (so the local fallback can run)
|
|
5289
|
+
@@ -95,7 +107,7 @@ function getPluginPathAndName(moduleName, paths, projects, root) {
|
|
5290
|
+
}
|
|
5291
|
+
if (!pluginPath) {
|
|
5292
|
+
try {
|
|
5293
|
+
- pluginPath = require.resolve(moduleName, { paths });
|
|
5294
|
+
+ pluginPath = require.resolve(fromRoot(moduleName, root), { paths });
|
|
5295
|
+
}
|
|
5296
|
+
catch (e) {
|
|
5297
|
+
if (localPlugin && isPackageResolutionError(e)) {
|
|
4558
5298
|
diff --git a/dist/src/project-graph/plugins/tasks-execution-hooks.js b/dist/src/project-graph/plugins/tasks-execution-hooks.js
|
|
4559
5299
|
index 867a717e26592ed291df332083e1aded275dc404..8af158796c275950c11c55953b6deb63ff353c95 100644
|
|
4560
5300
|
--- a/dist/src/project-graph/plugins/tasks-execution-hooks.js
|
|
@@ -4695,7 +5435,7 @@ index 3ab406eee377e39ebd9229a1d07b7b11c94413b2..1f14ec608e0386ce0918db7ca14f29a6
|
|
|
4695
5435
|
// Deliberately not disabled: unlike the inotify limit above, a socket
|
|
4696
5436
|
// owned by someone else stops being there when it is removed or the
|
|
4697
5437
|
diff --git a/dist/src/tasks-runner/cache.js b/dist/src/tasks-runner/cache.js
|
|
4698
|
-
index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..
|
|
5438
|
+
index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..23c356d6c628374336b1919e95fa10ce5770c8a3 100644
|
|
4699
5439
|
--- a/dist/src/tasks-runner/cache.js
|
|
4700
5440
|
+++ b/dist/src/tasks-runner/cache.js
|
|
4701
5441
|
@@ -28,6 +28,7 @@ const workspace_root_1 = require("../utils/workspace-root");
|
|
@@ -4725,7 +5465,18 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1
|
|
|
4725
5465
|
}
|
|
4726
5466
|
async put(task, terminalOutput, outputs, code) {
|
|
4727
5467
|
return tryAndRetry(async () => {
|
|
4728
|
-
@@ -
|
|
5468
|
+
@@ -183,7 +194,9 @@ class DbCache {
|
|
5469
|
+
// Notify TaskIOService of actual output files
|
|
5470
|
+
(0, task_io_service_1.getTaskIOService)().notifyTaskOutputs(task.id, expandedOutputs);
|
|
5471
|
+
if (this.remoteCache) {
|
|
5472
|
+
- await this.remoteCache.store(task.hash, this.cache.cacheDirectory, terminalOutput, code);
|
|
5473
|
+
+ // A store policy (NX_SELF_HOSTED_REMOTE_CACHE_STORE_SECONDS_PER_MIB) decides on how long the task
|
|
5474
|
+
+ // ran, before any archive is built. The orchestrator sets both times before it calls put.
|
|
5475
|
+
+ await this.remoteCache.store(task.hash, this.cache.cacheDirectory, terminalOutput, code, task.endTime - task.startTime);
|
|
5476
|
+
}
|
|
5477
|
+
return files;
|
|
5478
|
+
});
|
|
5479
|
+
@@ -198,7 +211,7 @@ class DbCache {
|
|
4729
5480
|
this.cache.recordTerminalOutputs(records);
|
|
4730
5481
|
}
|
|
4731
5482
|
copyFilesFromCache(_, cachedResult, outputs) {
|
|
@@ -4734,17 +5485,18 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1
|
|
|
4734
5485
|
}
|
|
4735
5486
|
removeOldCacheRecords() {
|
|
4736
5487
|
return this.cache.removeOldCacheRecords();
|
|
4737
|
-
@@ -293,7 +
|
|
5488
|
+
@@ -293,7 +306,9 @@ class DbCache {
|
|
4738
5489
|
if (process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0') {
|
|
4739
5490
|
process.emitWarning("Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.");
|
|
4740
5491
|
}
|
|
4741
5492
|
- return new native_1.HttpRemoteCache();
|
|
4742
5493
|
+ const guard = new remote_cache_outage_1.RemoteCacheOutageGuard(new native_1.HttpRemoteCache(), process.env.NX_SELF_HOSTED_REMOTE_CACHE_SERVER);
|
|
4743
|
-
+
|
|
5494
|
+
+ const secondsPerMiB = (0, remote_cache_outage_1.parseStoreSecondsPerMiB)(process.env.NX_SELF_HOSTED_REMOTE_CACHE_STORE_SECONDS_PER_MIB);
|
|
5495
|
+
+ return secondsPerMiB === null ? guard : new remote_cache_outage_1.CostBoundRemoteCache(guard, secondsPerMiB);
|
|
4744
5496
|
}
|
|
4745
5497
|
return null;
|
|
4746
5498
|
}
|
|
4747
|
-
@@ -452,6 +
|
|
5499
|
+
@@ -452,6 +467,7 @@ class Cache {
|
|
4748
5500
|
await this.copy(cached, src);
|
|
4749
5501
|
}
|
|
4750
5502
|
}));
|
|
@@ -4752,7 +5504,7 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1
|
|
|
4752
5504
|
});
|
|
4753
5505
|
}
|
|
4754
5506
|
temporaryOutputPath(task) {
|
|
4755
|
-
@@ -557,6 +
|
|
5507
|
+
@@ -557,6 +573,213 @@ class Cache {
|
|
4756
5508
|
}
|
|
4757
5509
|
}
|
|
4758
5510
|
exports.Cache = Cache;
|
|
@@ -4812,8 +5564,20 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1
|
|
|
4812
5564
|
+ * never wrote: what a run on other inputs left, which the restored task's
|
|
4813
5565
|
+ * consumers then read as its output.
|
|
4814
5566
|
+ */
|
|
5567
|
+
+/**
|
|
5568
|
+
+ * The outputs the cache entry at `outputsPath` holds. Native `expandOutputs` follows links, so it drops a literal
|
|
5569
|
+
+ * output that is a link whose target lies outside the entry (`.runtime/bun -> ../.cache/runtime-bun/bun`): the entry
|
|
5570
|
+
+ * holds the link, and its target is the workspace's. A literal output is the entry's when the entry holds anything at
|
|
5571
|
+
+ * its path; a pattern expands as before.
|
|
5572
|
+
+ */
|
|
5573
|
+
+function entryOutputs(outputsPath, outputs) {
|
|
5574
|
+
+ const literal = outputs.filter((output) => !/[!*?[\]{}()]/.test(output));
|
|
5575
|
+
+ const patterns = outputs.filter((output) => /[!*?[\]{}()]/.test(output));
|
|
5576
|
+
+ const held = literal.filter((output) => (0, node_fs_1.lstatSync)((0, path_1.join)(outputsPath, output), { throwIfNoEntry: false }) !== undefined);
|
|
5577
|
+
+ return patterns.length === 0 ? held : [...held, ...(0, native_1.expandOutputs)(outputsPath, patterns)];
|
|
5578
|
+
+}
|
|
4815
5579
|
+function removeAbsentOutputs(workspaceRoot, outputsPath, outputs) {
|
|
4816
|
-
+ const cached = new Set((
|
|
5580
|
+
+ const cached = new Set(entryOutputs(outputsPath, outputs));
|
|
4817
5581
|
+ for (const output of (0, native_1.expandOutputs)(workspaceRoot, outputs)) {
|
|
4818
5582
|
+ if (!cached.has(output)) {
|
|
4819
5583
|
+ (0, node_fs_1.rmSync)((0, path_1.join)(workspaceRoot, output), { recursive: true, force: true });
|
|
@@ -4845,7 +5609,7 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1
|
|
|
4845
5609
|
+ removeAbsentOutputs(workspaceRoot, outputsPath, outputs);
|
|
4846
5610
|
+ const changed = [];
|
|
4847
5611
|
+ const kept = [];
|
|
4848
|
-
+ for (const output of (
|
|
5612
|
+
+ for (const output of entryOutputs(outputsPath, outputs)) {
|
|
4849
5613
|
+ collectChangedOutputs(outputsPath, workspaceRoot, output, changed, kept);
|
|
4850
5614
|
+ }
|
|
4851
5615
|
+ let written = [];
|
|
@@ -4874,8 +5638,9 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1
|
|
|
4874
5638
|
+ const present = (0, node_fs_1.lstatSync)(presentPath, { bigint: true, throwIfNoEntry: false });
|
|
4875
5639
|
+ if (cached.isDirectory()) {
|
|
4876
5640
|
+ if (!present?.isDirectory()) {
|
|
4877
|
-
+
|
|
4878
|
-
+
|
|
5641
|
+
+ // Made here and filled entry by entry, so a link inside it is restored as one too.
|
|
5642
|
+
+ (0, node_fs_1.rmSync)(presentPath, { recursive: true, force: true });
|
|
5643
|
+
+ (0, node_fs_1.mkdirSync)(presentPath, { recursive: true });
|
|
4879
5644
|
+ }
|
|
4880
5645
|
+ const names = (0, node_fs_1.readdirSync)(cachedPath);
|
|
4881
5646
|
+ const cachedNames = new Set(names);
|
|
@@ -4889,9 +5654,14 @@ index 02b4d14fca9314d8f4f277aa0aa1cb5b3c9736c8..dcf01c48e2ff13e8c61e91c4c1a5eea1
|
|
|
4889
5654
|
+ }
|
|
4890
5655
|
+ }
|
|
4891
5656
|
+ else if (cached.isSymbolicLink()) {
|
|
4892
|
-
+
|
|
4893
|
-
+
|
|
4894
|
-
+
|
|
5657
|
+
+ const linked = (0, node_fs_1.readlinkSync)(cachedPath);
|
|
5658
|
+
+ if (!present?.isSymbolicLink() || (0, node_fs_1.readlinkSync)(presentPath) !== linked) {
|
|
5659
|
+
+ // The link as the entry holds it. The native copy follows it inside the entry, where a target outside the
|
|
5660
|
+
+ // outputs (`.runtime/bun -> ../.cache/runtime-bun/bun`) is not, and after removing the workspace's
|
|
5661
|
+
+ // link it wrote nothing back.
|
|
5662
|
+
+ (0, node_fs_1.rmSync)(presentPath, { recursive: true, force: true });
|
|
5663
|
+
+ (0, node_fs_1.mkdirSync)((0, path_1.dirname)(presentPath), { recursive: true });
|
|
5664
|
+
+ (0, node_fs_1.symlinkSync)(linked, presentPath);
|
|
4895
5665
|
+ }
|
|
4896
5666
|
+ // The native copy stamps a link by what it points at, and only a file.
|
|
4897
5667
|
+ const target = (0, node_fs_1.statSync)(presentPath, { bigint: true, throwIfNoEntry: false });
|
|
@@ -5306,10 +6076,10 @@ index 0000000000000000000000000000000000000000..80e276f0681686cf4f47829bbdcfa705
|
|
|
5306
6076
|
+}
|
|
5307
6077
|
diff --git a/dist/src/tasks-runner/remote-cache-outage.d.ts b/dist/src/tasks-runner/remote-cache-outage.d.ts
|
|
5308
6078
|
new file mode 100644
|
|
5309
|
-
index 0000000000000000000000000000000000000000..
|
|
6079
|
+
index 0000000000000000000000000000000000000000..6a09eaddf12b558dbe78044e715e617f3ab1f2d5
|
|
5310
6080
|
--- /dev/null
|
|
5311
6081
|
+++ b/dist/src/tasks-runner/remote-cache-outage.d.ts
|
|
5312
|
-
@@ -0,0 +1,
|
|
6082
|
+
@@ -0,0 +1,52 @@
|
|
5313
6083
|
+import type { CachedResult } from '../native';
|
|
5314
6084
|
+import type { RemoteCacheV2 } from './default-tasks-runner';
|
|
5315
6085
|
+export declare const REMOTE_CACHE_ANSWER_WITHIN_MS = 90000;
|
|
@@ -5350,23 +6120,32 @@ index 0000000000000000000000000000000000000000..aecbe296f6bf80377fca38969c6efbf6
|
|
|
5350
6120
|
+ store(hash: string, cacheDirectory: string, terminalOutput: string, code: number): Promise<boolean>;
|
|
5351
6121
|
+ private request;
|
|
5352
6122
|
+}
|
|
5353
|
-
+export declare
|
|
6123
|
+
+export declare function parseStoreSecondsPerMiB(value: string | undefined): number | null;
|
|
6124
|
+
+export declare function isWorthStoring(builtInMs: number | undefined, outputBytes: number, secondsPerMiB: number): boolean;
|
|
6125
|
+
+export declare function outputBytesOf(directory: string): Promise<number>;
|
|
6126
|
+
+export declare class CostBoundRemoteCache implements RemoteCacheV2 {
|
|
5354
6127
|
+ private readonly remote;
|
|
5355
|
-
+
|
|
6128
|
+
+ private readonly secondsPerMiB;
|
|
6129
|
+
+ private readonly measure;
|
|
6130
|
+
+ private measureFailureSaid;
|
|
6131
|
+
+ constructor(remote: RemoteCacheV2, secondsPerMiB: number, measure?: (entryDirectory: string) => Promise<number>);
|
|
5356
6132
|
+ retrieve(hash: string, cacheDirectory: string): Promise<CachedResult | null>;
|
|
5357
|
-
+ store(hash: string, cacheDirectory: string, terminalOutput: string, code: number): Promise<boolean>;
|
|
6133
|
+
+ store(hash: string, cacheDirectory: string, terminalOutput: string, code: number, builtInMs?: number): Promise<boolean>;
|
|
5358
6134
|
+}
|
|
5359
6135
|
diff --git a/dist/src/tasks-runner/remote-cache-outage.js b/dist/src/tasks-runner/remote-cache-outage.js
|
|
5360
6136
|
new file mode 100644
|
|
5361
|
-
index 0000000000000000000000000000000000000000..
|
|
6137
|
+
index 0000000000000000000000000000000000000000..85a6d257c34dd84bb2acc85b62f4e0e97aed9e69
|
|
5362
6138
|
--- /dev/null
|
|
5363
6139
|
+++ b/dist/src/tasks-runner/remote-cache-outage.js
|
|
5364
|
-
@@ -0,0 +1,
|
|
6140
|
+
@@ -0,0 +1,264 @@
|
|
5365
6141
|
+"use strict";
|
|
5366
6142
|
+Object.defineProperty(exports, "__esModule", { value: true });
|
|
5367
|
-
+exports.
|
|
6143
|
+
+exports.CostBoundRemoteCache = exports.RemoteCacheOutageGuard = exports.REMOTE_CACHE_ANSWER_WITHIN_MS = void 0;
|
|
5368
6144
|
+exports.settleRemoteCacheRequest = settleRemoteCacheRequest;
|
|
5369
6145
|
+exports.describeRemoteCacheOutage = describeRemoteCacheOutage;
|
|
6146
|
+
+exports.parseStoreSecondsPerMiB = parseStoreSecondsPerMiB;
|
|
6147
|
+
+exports.isWorthStoring = isWorthStoring;
|
|
6148
|
+
+exports.outputBytesOf = outputBytesOf;
|
|
5370
6149
|
+const node_fs_1 = require("node:fs");
|
|
5371
6150
|
+const promises_1 = require("node:fs/promises");
|
|
5372
6151
|
+const path_1 = require("node:path");
|
|
@@ -5527,21 +6306,76 @@ index 0000000000000000000000000000000000000000..c8d00d0f94ed40dfc27b4ffaf0018311
|
|
|
5527
6306
|
+}
|
|
5528
6307
|
+exports.RemoteCacheOutageGuard = RemoteCacheOutageGuard;
|
|
5529
6308
|
+/**
|
|
5530
|
-
+ *
|
|
5531
|
-
+ *
|
|
6309
|
+
+ * The bytes of one task result's entry directory: the outputs and terminal output Nx's native `store` archives. A
|
|
6310
|
+
+ * symbolic link counts nothing: the bytes of its own path are not an output's.
|
|
6311
|
+
+ */
|
|
6312
|
+
+async function outputBytesOf(directory) {
|
|
6313
|
+
+ let bytes = 0;
|
|
6314
|
+
+ for (const entry of await (0, promises_1.readdir)(directory, { recursive: true, withFileTypes: true })) {
|
|
6315
|
+
+ if (entry.isFile()) {
|
|
6316
|
+
+ bytes += (await (0, promises_1.stat)((0, path_1.join)(entry.parentPath ?? entry.path, entry.name))).size;
|
|
6317
|
+
+ }
|
|
6318
|
+
+ }
|
|
6319
|
+
+ return bytes;
|
|
6320
|
+
+}
|
|
6321
|
+
+const BYTES_PER_MIB = 1024 * 1024;
|
|
6322
|
+
+const STORE_BOUND_ENV = 'NX_SELF_HOSTED_REMOTE_CACHE_STORE_SECONDS_PER_MIB';
|
|
6323
|
+
+/**
|
|
6324
|
+
+ * Reads NX_SELF_HOSTED_REMOTE_CACHE_STORE_SECONDS_PER_MIB: null when it is unset, so the client stores as stock Nx
|
|
6325
|
+
+ * does, else the seconds of build time a result must have per MiB of outputs. Any other value is misconfiguration and
|
|
6326
|
+
+ * fails the run, naming the variable and the value.
|
|
5532
6327
|
+ */
|
|
5533
|
-
+
|
|
5534
|
-
+
|
|
6328
|
+
+function parseStoreSecondsPerMiB(value) {
|
|
6329
|
+
+ if (value === undefined || value === '') {
|
|
6330
|
+
+ return null;
|
|
6331
|
+
+ }
|
|
6332
|
+
+ if (!/^\d+(\.\d+)?$/.test(value)) {
|
|
6333
|
+
+ throw new Error(STORE_BOUND_ENV + ' must be a number of seconds, 0 or more: got ' + JSON.stringify(value));
|
|
6334
|
+
+ }
|
|
6335
|
+
+ return Number(value);
|
|
6336
|
+
+}
|
|
6337
|
+
+/**
|
|
6338
|
+
+ * Whether a result that took `builtInMs` to build and holds `outputBytes` of outputs saves enough to be stored: at
|
|
6339
|
+
+ * least `secondsPerMiB` seconds per MiB of outputs, counting at least one MiB. A build time that is not a number is
|
|
6340
|
+
+ * never worth it.
|
|
6341
|
+
+ */
|
|
6342
|
+
+function isWorthStoring(builtInMs, outputBytes, secondsPerMiB) {
|
|
6343
|
+
+ return builtInMs / 1000 >= secondsPerMiB * Math.max(1, outputBytes / BYTES_PER_MIB);
|
|
6344
|
+
+}
|
|
6345
|
+
+/**
|
|
6346
|
+
+ * A checkout stores the tasks it executed that are worth their bytes and no other (specs/cowshed/03_caches.md "What a
|
|
6347
|
+
+ * checkout stores"). `store` answers false, before any archive is built, for a result that took less than the bound asks.
|
|
6348
|
+
+ */
|
|
6349
|
+
+class CostBoundRemoteCache {
|
|
6350
|
+
+ constructor(remote, secondsPerMiB, measure = outputBytesOf) {
|
|
5535
6351
|
+ this.remote = remote;
|
|
6352
|
+
+ this.secondsPerMiB = secondsPerMiB;
|
|
6353
|
+
+ this.measure = measure;
|
|
6354
|
+
+ this.measureFailureSaid = false;
|
|
5536
6355
|
+ }
|
|
5537
6356
|
+ retrieve(hash, cacheDirectory) {
|
|
5538
6357
|
+ return this.remote.retrieve(hash, cacheDirectory);
|
|
5539
6358
|
+ }
|
|
5540
|
-
+ async store() {
|
|
5541
|
-
+
|
|
6359
|
+
+ async store(hash, cacheDirectory, terminalOutput, code, builtInMs) {
|
|
6360
|
+
+ let bytes;
|
|
6361
|
+
+ try {
|
|
6362
|
+
+ bytes = await this.measure((0, path_1.join)(cacheDirectory, hash));
|
|
6363
|
+
+ }
|
|
6364
|
+
+ catch (error) {
|
|
6365
|
+
+ if (!this.measureFailureSaid) {
|
|
6366
|
+
+ this.measureFailureSaid = true;
|
|
6367
|
+
+ logger_1.logger.warn('Remote cache store skipped: could not measure the outputs of ' + hash + ' (' + oneLine(String(error)) + ')');
|
|
6368
|
+
+ }
|
|
6369
|
+
+ return false;
|
|
6370
|
+
+ }
|
|
6371
|
+
+ if (!isWorthStoring(builtInMs, bytes, this.secondsPerMiB)) {
|
|
6372
|
+
+ logger_1.logger.verbose('Remote cache: not storing ' + hash + ', built in ' + builtInMs + ' ms with ' + bytes + ' bytes of outputs (' + STORE_BOUND_ENV + '=' + this.secondsPerMiB + ')');
|
|
6373
|
+
+ return false;
|
|
6374
|
+
+ }
|
|
6375
|
+
+ return this.remote.store(hash, cacheDirectory, terminalOutput, code);
|
|
5542
6376
|
+ }
|
|
5543
6377
|
+}
|
|
5544
|
-
+exports.
|
|
6378
|
+
+exports.CostBoundRemoteCache = CostBoundRemoteCache;
|
|
5545
6379
|
+/** Staging directories not yet removed; the process removes what is left as it exits. */
|
|
5546
6380
|
+const unsettledStaging = new Set();
|
|
5547
6381
|
+process.on('exit', () => {
|
|
@@ -5593,6 +6427,90 @@ index b068c8bb203fd47d11e0d5cdc411b4444fc244fd..851d4428983a7e32aafd059580cfbc82
|
|
|
5593
6427
|
return;
|
|
5594
6428
|
}
|
|
5595
6429
|
const { outdatedAgents } = await client_1.daemonClient.getConfigureAiAgentsStatus();
|
|
6430
|
+
diff --git a/dist/src/tasks-runner/running-tasks/batch-process.js b/dist/src/tasks-runner/running-tasks/batch-process.js
|
|
6431
|
+
index 4c56ddede1856427cf936950e2771bf8f9322e92..9c3b57391a002f29a4f5a72c1d925050a8efe31a 100644
|
|
6432
|
+
--- a/dist/src/tasks-runner/running-tasks/batch-process.js
|
|
6433
|
+
+++ b/dist/src/tasks-runner/running-tasks/batch-process.js
|
|
6434
|
+
@@ -6,6 +6,7 @@ const crypto_1 = require("crypto");
|
|
6435
|
+
const path_1 = require("path");
|
|
6436
|
+
const native_1 = require("../../native");
|
|
6437
|
+
const cache_1 = require("../cache");
|
|
6438
|
+
+const child_process_1 = require("../../utils/child-process");
|
|
6439
|
+
const exit_codes_1 = require("../../utils/exit-codes");
|
|
6440
|
+
const output_1 = require("../../utils/output");
|
|
6441
|
+
const batch_messages_1 = require("../batch/batch-messages");
|
|
6442
|
+
@@ -68,6 +69,7 @@ class BatchProcess {
|
|
6443
|
+
* summary is still pointing at.
|
|
6444
|
+
*/
|
|
6445
|
+
this.captureNonce = (0, crypto_1.randomBytes)(4).toString('hex');
|
|
6446
|
+
+ this.stdioClosed = (0, child_process_1.whenStdioClosed)(this.childProcess);
|
|
6447
|
+
this.childProcess.on('message', (message) => {
|
|
6448
|
+
switch (message.type) {
|
|
6449
|
+
case batch_messages_1.BatchMessageType.CompleteTask: {
|
|
6450
|
+
@@ -294,8 +296,8 @@ class BatchProcess {
|
|
6451
|
+
* batch as one fold, so output no task claimed is not lost.
|
|
6452
|
+
*
|
|
6453
|
+
* Not valid to read before `flushCapturedOutput`; that flush ends the stream,
|
|
6454
|
+
- * so a chunk arriving afterwards - a worker's stdout can deliver past the
|
|
6455
|
+
- * exit event `getResults()` settles on - is dropped rather than appended.
|
|
6456
|
+
+ * so a chunk arriving afterwards - a worker can still write after the
|
|
6457
|
+
+ * results message `getResults()` settles on - is dropped rather than appended.
|
|
6458
|
+
*/
|
|
6459
|
+
getCapturedOutputPath() {
|
|
6460
|
+
return this.capturedOutputPath;
|
|
6461
|
+
@@ -341,7 +343,9 @@ class BatchProcess {
|
|
6462
|
+
new Promise((_, rej) => {
|
|
6463
|
+
this.onExit((code) => {
|
|
6464
|
+
if (code !== 0) {
|
|
6465
|
+
- rej(new Error(`"${this.executorName}" exited unexpectedly with code: ${code}`));
|
|
6466
|
+
+ // A rejection makes the caller flush the capture, which drops
|
|
6467
|
+
+ // whatever the crashed worker wrote that has not been read yet.
|
|
6468
|
+
+ this.stdioClosed.then(() => rej(new Error(`"${this.executorName}" exited unexpectedly with code: ${code}`)));
|
|
6469
|
+
}
|
|
6470
|
+
});
|
|
6471
|
+
}),
|
|
6472
|
+
diff --git a/dist/src/tasks-runner/task-env.js b/dist/src/tasks-runner/task-env.js
|
|
6473
|
+
index bded0d604f20417f61fdf18bcf62b09966847d43..2aa4f9cde2f677b89032b439ef90c7c7ee68f977 100644
|
|
6474
|
+
--- a/dist/src/tasks-runner/task-env.js
|
|
6475
|
+
+++ b/dist/src/tasks-runner/task-env.js
|
|
6476
|
+
@@ -49,29 +49,20 @@ function getEnvVariablesForBatchProcess(skipNxCache, captureStderr) {
|
|
6477
|
+
delete res[ready_signal_1.READY_URL_ENV];
|
|
6478
|
+
return res;
|
|
6479
|
+
}
|
|
6480
|
+
-// The orchestrator now calls this eagerly during the coordinator pre-hash
|
|
6481
|
+
-// in addition to processTask (and again in hashBatchTasks), so the same
|
|
6482
|
+
-// task hits this function multiple times per run. Each call reads 3+ .env
|
|
6483
|
+
-// files from disk — memoize by task.id to skip the repeat work.
|
|
6484
|
+
-//
|
|
6485
|
+
-// Cache lifetime is the current Nx invocation: the function is only called
|
|
6486
|
+
-// from CLI/orchestrator code (not the long-lived daemon), so the map is
|
|
6487
|
+
-// scoped to a single run. Callers must not mutate the returned env — they
|
|
6488
|
+
-// already spread it into new objects before adding task-specific overrides
|
|
6489
|
+
-// (see getEnvVariablesForTask).
|
|
6490
|
+
-const taskSpecificEnvCache = new Map();
|
|
6491
|
+
+// The environment a task is hashed and forked with: the ambient env with the root dotenv files Nx loaded on init
|
|
6492
|
+
+// unloaded, then the task's own dotenv files. It reads `process.env` as it stands, so what a run's preTasksExecution
|
|
6493
|
+
+// published reaches that run's tasks. A run reads it once per task through its orchestrator
|
|
6494
|
+
+// (`TaskOrchestrator.taskSpecificEnv`), whose memo lives exactly as long as the run. A module-level memo outlived the
|
|
6495
|
+
+// invocation in a client that runs several in one process, and hashed and forked a later run's tasks with the first
|
|
6496
|
+
+// run's environment. Callers must not mutate the returned env — they already spread it into new objects before adding
|
|
6497
|
+
+// task-specific overrides (see getEnvVariablesForTask).
|
|
6498
|
+
function getTaskSpecificEnv(task, graph) {
|
|
6499
|
+
- const cached = taskSpecificEnvCache.get(task.id);
|
|
6500
|
+
- if (cached)
|
|
6501
|
+
- return cached;
|
|
6502
|
+
// Unload any dot env files at the root of the workspace that were loaded on init of Nx.
|
|
6503
|
+
const taskEnv = unloadDotEnvFiles({ ...process.env });
|
|
6504
|
+
- const env = process.env.NX_LOAD_DOT_ENV_FILES === 'true'
|
|
6505
|
+
+ return process.env.NX_LOAD_DOT_ENV_FILES === 'true'
|
|
6506
|
+
? loadDotEnvFilesForTask(task, graph, taskEnv)
|
|
6507
|
+
: // If not loading dot env files, ensure env vars created by system are still loaded
|
|
6508
|
+
taskEnv;
|
|
6509
|
+
- taskSpecificEnvCache.set(task.id, env);
|
|
6510
|
+
- return env;
|
|
6511
|
+
}
|
|
6512
|
+
/**
|
|
6513
|
+
* Reconstructs, at graph-construction time, the env a task would see: the
|
|
5596
6514
|
diff --git a/dist/src/tasks-runner/task-graph-utils.d.ts b/dist/src/tasks-runner/task-graph-utils.d.ts
|
|
5597
6515
|
index c808d03befeaa74a79967f03c5a0dcf86685c2e7..024f58d5b865e4080bc6fd47584838567219ec6e 100644
|
|
5598
6516
|
--- a/dist/src/tasks-runner/task-graph-utils.d.ts
|
|
@@ -5690,10 +6608,18 @@ index f9f93ce62eab9448a72ad9d95b962067de113f1c..8657ded47a3b9df09d7a7ee8ed04490e
|
|
|
5690
6608
|
}
|
|
5691
6609
|
return cycles.size ? cycles : null;
|
|
5692
6610
|
diff --git a/dist/src/tasks-runner/task-orchestrator.d.ts b/dist/src/tasks-runner/task-orchestrator.d.ts
|
|
5693
|
-
index b0d3c985bc330a54b43df557d3e247e1bf64e060..
|
|
6611
|
+
index b0d3c985bc330a54b43df557d3e247e1bf64e060..ff7cd099c7a2092bdba5d1232ee7357028e63ab9 100644
|
|
5694
6612
|
--- a/dist/src/tasks-runner/task-orchestrator.d.ts
|
|
5695
6613
|
+++ b/dist/src/tasks-runner/task-orchestrator.d.ts
|
|
5696
|
-
@@ -
|
|
6614
|
+
@@ -42,6 +42,7 @@ export declare class TaskOrchestrator {
|
|
6615
|
+
private reverseTaskDeps;
|
|
6616
|
+
private initializingTaskIds;
|
|
6617
|
+
private processedTasks;
|
|
6618
|
+
+ private readonly taskSpecificEnvs;
|
|
6619
|
+
private cacheMissedHashes;
|
|
6620
|
+
private copiedOutputFiles;
|
|
6621
|
+
private completedTasks;
|
|
6622
|
+
@@ -49,6 +50,8 @@ export declare class TaskOrchestrator {
|
|
5697
6623
|
private pendingDiscreteWorkers;
|
|
5698
6624
|
private groups;
|
|
5699
6625
|
private continuousTasksStarted;
|
|
@@ -5702,7 +6628,7 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5702
6628
|
/**
|
|
5703
6629
|
* How many folds each batch id has rendered. A batch that reports a strict
|
|
5704
6630
|
* subset of its tasks is re-run under the same id, so one id can produce more
|
|
5705
|
-
@@ -58,6 +
|
|
6631
|
+
@@ -58,6 +61,7 @@ export declare class TaskOrchestrator {
|
|
5706
6632
|
private bailed;
|
|
5707
6633
|
private resolveStopPromise;
|
|
5708
6634
|
private stopRequested;
|
|
@@ -5710,7 +6636,7 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5710
6636
|
private runningContinuousTasks;
|
|
5711
6637
|
private runningRunCommandsTasks;
|
|
5712
6638
|
private runningDiscreteTasks;
|
|
5713
|
-
@@ -73,6 +
|
|
6639
|
+
@@ -73,6 +77,8 @@ export declare class TaskOrchestrator {
|
|
5714
6640
|
private cleanupPromise;
|
|
5715
6641
|
private signalHandlers;
|
|
5716
6642
|
private tasksWithPersistedOutput;
|
|
@@ -5719,7 +6645,7 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5719
6645
|
constructor(hasher: TaskHasher, initiatingProject: string | undefined, initiatingTasks: Task[], projectGraph: ProjectGraph, taskGraph: TaskGraph, nxJson: NxJsonConfiguration, options: NxArgs & DefaultTasksRunnerOptions, bail: boolean, daemon: DaemonClient,
|
|
5720
6646
|
/** What the user named; undefined means they named nothing. */
|
|
5721
6647
|
specifiedOutputStyle: OutputStyle | undefined,
|
|
5722
|
-
@@ -84,6 +
|
|
6648
|
+
@@ -84,6 +90,7 @@ export declare class TaskOrchestrator {
|
|
5723
6649
|
run(): Promise<{
|
|
5724
6650
|
[k: string]: TaskStatus;
|
|
5725
6651
|
}>;
|
|
@@ -5727,7 +6653,15 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5727
6653
|
nextBatch(): Batch;
|
|
5728
6654
|
/**
|
|
5729
6655
|
* Coordinator loop. All batch operations (hashing, cache resolution)
|
|
5730
|
-
@@ -
|
|
6656
|
+
@@ -99,6 +106,7 @@ export declare class TaskOrchestrator {
|
|
6657
|
+
private executeContinuousTaskLoop;
|
|
6658
|
+
private hasUnresolvedCacheableTask;
|
|
6659
|
+
private scheduleAfterReadiness;
|
|
6660
|
+
+ private taskSpecificEnv;
|
|
6661
|
+
private processTask;
|
|
6662
|
+
processAllScheduledTasks(): void;
|
|
6663
|
+
processTasks(taskIds: string[]): void;
|
|
6664
|
+
@@ -136,12 +144,9 @@ export declare class TaskOrchestrator {
|
|
5731
6665
|
* cache fetch + lifecycle to the public method. Returns true if any
|
|
5732
6666
|
* tasks were resolved.
|
|
5733
6667
|
*
|
|
@@ -5743,7 +6677,7 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5743
6677
|
*/
|
|
5744
6678
|
private resolveCachedTasksBulk;
|
|
5745
6679
|
/**
|
|
5746
|
-
@@ -158,6 +
|
|
6680
|
+
@@ -158,6 +163,7 @@ export declare class TaskOrchestrator {
|
|
5747
6681
|
private applyBatchCachedResults;
|
|
5748
6682
|
private hashBatchTasks;
|
|
5749
6683
|
applyFromCacheOrRunBatch(doNotSkipCache: boolean, batch: Batch, groupId: number): Promise<TaskResult[]>;
|
|
@@ -5751,7 +6685,7 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5751
6685
|
private runBatchWave;
|
|
5752
6686
|
private runBatch;
|
|
5753
6687
|
/**
|
|
5754
|
-
@@ -252,12 +
|
|
6688
|
+
@@ -252,12 +258,11 @@ export declare class TaskOrchestrator {
|
|
5755
6689
|
* don't actually compete for parallelism.
|
|
5756
6690
|
*/
|
|
5757
6691
|
resolveCachedTasks(doNotSkipCache: boolean, tasks: Task[], groupId: number): Promise<TaskResult[]>;
|
|
@@ -5767,7 +6701,7 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5767
6701
|
*/
|
|
5768
6702
|
private dispatchDiscreteWorker;
|
|
5769
6703
|
/**
|
|
5770
|
-
@@ -269,11 +
|
|
6704
|
+
@@ -269,11 +274,14 @@ export declare class TaskOrchestrator {
|
|
5771
6705
|
*/
|
|
5772
6706
|
private handleDiscreteWorkerFailure;
|
|
5773
6707
|
/**
|
|
@@ -5786,7 +6720,7 @@ index b0d3c985bc330a54b43df557d3e247e1bf64e060..30dbf685a4b05ceb19e27b0b262d821b
|
|
|
5786
6720
|
private runTaskInForkedProcess;
|
|
5787
6721
|
startContinuousTask(task: Task, groupId: number): Promise<NoopChildProcess | RunningTask | SharedRunningTask>;
|
|
5788
6722
|
diff --git a/dist/src/tasks-runner/task-orchestrator.js b/dist/src/tasks-runner/task-orchestrator.js
|
|
5789
|
-
index 9a17f88be6502a302c5f5eab71df646a2f87851c..
|
|
6723
|
+
index 9a17f88be6502a302c5f5eab71df646a2f87851c..8fc11ce4af48b49d7055f8bdbb9d0d8d8882119b 100644
|
|
5790
6724
|
--- a/dist/src/tasks-runner/task-orchestrator.js
|
|
5791
6725
|
+++ b/dist/src/tasks-runner/task-orchestrator.js
|
|
5792
6726
|
@@ -32,6 +32,8 @@ const shared_running_task_1 = require("./running-tasks/shared-running-task");
|
|
@@ -5798,7 +6732,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5798
6732
|
/**
|
|
5799
6733
|
* Resolve a batch executor's per-task result to a TaskStatus. Prefers an
|
|
5800
6734
|
* explicit `status` from the executor; falls back to the `success` boolean
|
|
5801
|
-
@@ -150,11 +152,
|
|
6735
|
+
@@ -150,11 +152,12 @@ class TaskOrchestrator {
|
|
5802
6736
|
// underlying real tasks become the anchors.
|
|
5803
6737
|
this.initializingTaskIds = (0, utils_1.expandInitiatingTasksThroughNoop)(this.initiatingTasks, this.taskGraph, this.projectGraph);
|
|
5804
6738
|
this.processedTasks = new Map();
|
|
@@ -5807,13 +6741,16 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5807
6741
|
- // schedule — so a missed hash never needs re-querying. Without this, a
|
|
5808
6742
|
- // miss waiting for a worker slot is re-queried (including the remote
|
|
5809
6743
|
- // retrieval) on every coordinator cycle.
|
|
6744
|
+
+ // Each task's environment for this run, read once: the coordinator's pre-hash, processTask and a batch's
|
|
6745
|
+
+ // hashing share it, and it ends with the run (`taskSpecificEnv`).
|
|
6746
|
+
+ this.taskSpecificEnvs = new Map();
|
|
5810
6747
|
+ // Probe a queued miss once, not on every coordinator wakeup.
|
|
5811
6748
|
+ // Output producers recheck after taking their cross-client lease: a
|
|
5812
6749
|
+ // foreign client can populate the key while this worker is queued.
|
|
5813
6750
|
this.cacheMissedHashes = new Set();
|
|
5814
6751
|
// The files the cache just wrote or restored, by task id, for postRunSteps
|
|
5815
6752
|
// to hand the daemon instead of it walking the outputs again.
|
|
5816
|
-
@@ -164,6 +
|
|
6753
|
+
@@ -164,6 +167,9 @@ class TaskOrchestrator {
|
|
5817
6754
|
this.pendingDiscreteWorkers = new Set();
|
|
5818
6755
|
this.groups = [];
|
|
5819
6756
|
this.continuousTasksStarted = 0;
|
|
@@ -5823,7 +6760,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5823
6760
|
/**
|
|
5824
6761
|
* How many folds each batch id has rendered. A batch that reports a strict
|
|
5825
6762
|
* subset of its tasks is re-run under the same id, so one id can produce more
|
|
5826
|
-
@@ -173,6 +
|
|
6763
|
+
@@ -173,6 +179,7 @@ class TaskOrchestrator {
|
|
5827
6764
|
this.bailed = false;
|
|
5828
6765
|
this.resolveStopPromise = null;
|
|
5829
6766
|
this.stopRequested = false;
|
|
@@ -5831,7 +6768,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5831
6768
|
this.runningContinuousTasks = new Map();
|
|
5832
6769
|
this.runningRunCommandsTasks = new Map();
|
|
5833
6770
|
this.runningDiscreteTasks = new Map();
|
|
5834
|
-
@@ -195,6 +
|
|
6771
|
+
@@ -195,6 +202,9 @@ class TaskOrchestrator {
|
|
5835
6772
|
// exit, and the paths that never spawn one write it inline. The backstop in
|
|
5836
6773
|
// postRunSteps consults this so a task's output is written exactly once.
|
|
5837
6774
|
this.tasksWithPersistedOutput = new Set();
|
|
@@ -5841,7 +6778,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5841
6778
|
}
|
|
5842
6779
|
async init() {
|
|
5843
6780
|
this.setupSignalHandlers();
|
|
5844
|
-
@@ -214,9 +
|
|
6781
|
+
@@ -214,9 +224,24 @@ class TaskOrchestrator {
|
|
5845
6782
|
}
|
|
5846
6783
|
}
|
|
5847
6784
|
async run() {
|
|
@@ -5866,7 +6803,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5866
6803
|
process.stdout.setMaxListeners(total + events_1.defaultMaxListeners);
|
|
5867
6804
|
process.stderr.setMaxListeners(total + events_1.defaultMaxListeners);
|
|
5868
6805
|
process.setMaxListeners(total + events_1.defaultMaxListeners);
|
|
5869
|
-
@@ -252,8 +
|
|
6806
|
+
@@ -252,8 +277,6 @@ class TaskOrchestrator {
|
|
5870
6807
|
// the native half does not exist.
|
|
5871
6808
|
(0, cache_1.sweepBatchOutputs)();
|
|
5872
6809
|
}
|
|
@@ -5875,7 +6812,16 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5875
6812
|
// Public API (defaultTasksRunner) returns a plain object keyed by
|
|
5876
6813
|
// task id. Internal state is a Map for faster lookup.
|
|
5877
6814
|
return Object.fromEntries(this.completedTasks);
|
|
5878
|
-
@@ -
|
|
6815
|
+
@@ -307,7 +330,7 @@ class TaskOrchestrator {
|
|
6816
|
+
if (unhashed.length > 0) {
|
|
6817
|
+
const perTaskEnvs = {};
|
|
6818
|
+
for (const task of unhashed) {
|
|
6819
|
+
- perTaskEnvs[task.id] = (0, task_env_1.getTaskSpecificEnv)(task, this.projectGraph);
|
|
6820
|
+
+ perTaskEnvs[task.id] = this.taskSpecificEnv(task);
|
|
6821
|
+
}
|
|
6822
|
+
await (0, hash_task_1.hashTasks)(this.hasher, this.projectGraph, this.fullTaskGraph, perTaskEnvs, this.taskDetails, unhashed);
|
|
6823
|
+
}
|
|
6824
|
+
@@ -345,6 +368,18 @@ class TaskOrchestrator {
|
|
5879
6825
|
const groupId = this.closeGroup();
|
|
5880
6826
|
this.dispatchDiscreteWorker(doNotSkipCache, task, groupId);
|
|
5881
6827
|
}
|
|
@@ -5894,7 +6840,27 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5894
6840
|
// 6. Nothing left to dispatch and nothing in flight — done.
|
|
5895
6841
|
if (!this.tasksSchedule.hasTasks() &&
|
|
5896
6842
|
this.pendingDiscreteWorkers.size === 0) {
|
|
5897
|
-
@@ -
|
|
6843
|
+
@@ -410,9 +445,18 @@ class TaskOrchestrator {
|
|
6844
|
+
}
|
|
6845
|
+
}
|
|
6846
|
+
// region Processing Scheduled Tasks
|
|
6847
|
+
+ /** `task`'s environment for this run, read once per task and kept only as long as this orchestrator. */
|
|
6848
|
+
+ taskSpecificEnv(task) {
|
|
6849
|
+
+ let env = this.taskSpecificEnvs.get(task.id);
|
|
6850
|
+
+ if (env === undefined) {
|
|
6851
|
+
+ env = (0, task_env_1.getTaskSpecificEnv)(task, this.projectGraph);
|
|
6852
|
+
+ this.taskSpecificEnvs.set(task.id, env);
|
|
6853
|
+
+ }
|
|
6854
|
+
+ return env;
|
|
6855
|
+
+ }
|
|
6856
|
+
async processTask(taskId) {
|
|
6857
|
+
const task = this.taskGraph.tasks[taskId];
|
|
6858
|
+
- const taskSpecificEnv = (0, task_env_1.getTaskSpecificEnv)(task, this.projectGraph);
|
|
6859
|
+
+ const taskSpecificEnv = this.taskSpecificEnv(task);
|
|
6860
|
+
if (!task.hash) {
|
|
6861
|
+
await (0, hash_task_1.hashTask)(this.hasher, this.projectGraph, this.fullTaskGraph, task, taskSpecificEnv, this.taskDetails);
|
|
6862
|
+
}
|
|
6863
|
+
@@ -581,12 +625,9 @@ class TaskOrchestrator {
|
|
5898
6864
|
* cache fetch + lifecycle to the public method. Returns true if any
|
|
5899
6865
|
* tasks were resolved.
|
|
5900
6866
|
*
|
|
@@ -5910,7 +6876,16 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5910
6876
|
*/
|
|
5911
6877
|
async resolveCachedTasksBulk() {
|
|
5912
6878
|
const { scheduledTasks } = this.tasksSchedule.getAllScheduledTasks();
|
|
5913
|
-
@@ -
|
|
6879
|
+
@@ -701,7 +742,7 @@ class TaskOrchestrator {
|
|
6880
|
+
// single-task path.
|
|
6881
|
+
const perTaskEnvs = {};
|
|
6882
|
+
for (const task of tasks) {
|
|
6883
|
+
- perTaskEnvs[task.id] = (0, task_env_1.getTaskSpecificEnv)(task, this.projectGraph);
|
|
6884
|
+
+ perTaskEnvs[task.id] = this.taskSpecificEnv(task);
|
|
6885
|
+
}
|
|
6886
|
+
await (0, hash_task_1.hashTasks)(this.hasher, this.projectGraph, this.fullTaskGraph, perTaskEnvs, this.taskDetails, tasks);
|
|
6887
|
+
}
|
|
6888
|
+
@@ -709,6 +750,17 @@ class TaskOrchestrator {
|
|
5914
6889
|
if (this.bailed || this.stopRequested) {
|
|
5915
6890
|
return [];
|
|
5916
6891
|
}
|
|
@@ -5928,7 +6903,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5928
6903
|
const applyFromCacheOrRunBatchStart = perf_hooks_1.performance.mark('TaskOrchestrator-apply-from-cache-or-run-batch:start');
|
|
5929
6904
|
const taskIds = Object.keys(batch.taskGraph.tasks);
|
|
5930
6905
|
this.options.lifeCycle.registerRunningBatch?.(batch.id, {
|
|
5931
|
-
@@ -1062,6 +
|
|
6906
|
+
@@ -1062,6 +1114,20 @@ class TaskOrchestrator {
|
|
5932
6907
|
* don't actually compete for parallelism.
|
|
5933
6908
|
*/
|
|
5934
6909
|
async resolveCachedTasks(doNotSkipCache, tasks, groupId) {
|
|
@@ -5949,7 +6924,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5949
6924
|
if (!doNotSkipCache || tasks.length === 0)
|
|
5950
6925
|
return [];
|
|
5951
6926
|
const cacheableTasks = tasks.filter((t) => t.cache);
|
|
5952
|
-
@@ -1088,10 +
|
|
6927
|
+
@@ -1088,10 +1154,8 @@ class TaskOrchestrator {
|
|
5953
6928
|
}
|
|
5954
6929
|
/**
|
|
5955
6930
|
* Fire a discrete-task worker and track it in pendingDiscreteWorkers until
|
|
@@ -5962,7 +6937,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5962
6937
|
*/
|
|
5963
6938
|
dispatchDiscreteWorker(doNotSkipCache, task, groupId) {
|
|
5964
6939
|
const worker = this.runTaskDirectly(doNotSkipCache, task, groupId)
|
|
5965
|
-
@@ -1125,9 +
|
|
6940
|
+
@@ -1125,9 +1189,11 @@ class TaskOrchestrator {
|
|
5966
6941
|
await this.postRunSteps([{ task, status: 'failure', terminalOutput }], doNotSkipCache, groupId);
|
|
5967
6942
|
}
|
|
5968
6943
|
/**
|
|
@@ -5977,7 +6952,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5977
6952
|
*/
|
|
5978
6953
|
async runTaskDirectly(doNotSkipCache, task, groupId) {
|
|
5979
6954
|
// Wait for task to be processed
|
|
5980
|
-
@@ -1155,6 +
|
|
6955
|
+
@@ -1155,6 +1221,18 @@ class TaskOrchestrator {
|
|
5981
6956
|
terminalOutput: waitError.message,
|
|
5982
6957
|
};
|
|
5983
6958
|
}
|
|
@@ -5996,7 +6971,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
5996
6971
|
await this.preRunSteps([task], { groupId });
|
|
5997
6972
|
const pipeOutput = await this.pipeOutputCapture(task);
|
|
5998
6973
|
const temporaryOutputPath = this.cache.temporaryOutputPath(task);
|
|
5999
|
-
@@ -1382,8 +
|
|
6974
|
+
@@ -1382,8 +1460,22 @@ class TaskOrchestrator {
|
|
6000
6975
|
}
|
|
6001
6976
|
}
|
|
6002
6977
|
async startContinuousTask(task, groupId) {
|
|
@@ -6021,7 +6996,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
6021
6996
|
// This branch never reads the hash, so a failure to compute it is dropped
|
|
6022
6997
|
void this.processedTasks.get(task.id)?.catch(() => { });
|
|
6023
6998
|
let readyWhen;
|
|
6024
|
-
@@ -1432,11 +
|
|
6999
|
+
@@ -1432,11 +1524,6 @@ class TaskOrchestrator {
|
|
6025
7000
|
await this.scheduleNextTasksAndReleaseThreads();
|
|
6026
7001
|
return runningTask;
|
|
6027
7002
|
}
|
|
@@ -6033,7 +7008,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
6033
7008
|
let pipeOutput;
|
|
6034
7009
|
let temporaryOutputPath;
|
|
6035
7010
|
let streamOutput;
|
|
6036
|
-
@@ -1485,7 +
|
|
7011
|
+
@@ -1485,7 +1572,11 @@ class TaskOrchestrator {
|
|
6037
7012
|
return new noop_child_process_1.NoopChildProcess({ code: 1, terminalOutput: '' });
|
|
6038
7013
|
}
|
|
6039
7014
|
let childProcess;
|
|
@@ -6045,7 +7020,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
6045
7020
|
await this.preRunSteps([task], { groupId });
|
|
6046
7021
|
this.detectTaskInvocationLoop(task);
|
|
6047
7022
|
childProcess = await this.runTask(task, streamOutput, env, temporaryOutputPath, pipeOutput);
|
|
6048
|
-
@@ -1515,15 +
|
|
7023
|
+
@@ -1515,15 +1606,19 @@ class TaskOrchestrator {
|
|
6049
7024
|
// release paths (completeContinuousTask, the signal handler) both iterate
|
|
6050
7025
|
// that map. Drop it here or siblings wait on a task no one is running.
|
|
6051
7026
|
this.runningTasksService?.removeRunningTask(task.id);
|
|
@@ -6072,7 +7047,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
6072
7047
|
});
|
|
6073
7048
|
}));
|
|
6074
7049
|
await this.scheduleNextTasksAndReleaseThreads();
|
|
6075
|
-
@@ -2114,22 +
|
|
7050
|
+
@@ -2114,22 +2209,32 @@ class TaskOrchestrator {
|
|
6076
7051
|
if (tasks.length === 0)
|
|
6077
7052
|
return resultMap;
|
|
6078
7053
|
if (this.daemon?.enabled()) {
|
|
@@ -6080,8 +7055,13 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
6080
7055
|
+ // A daemon gone under a client that may never start one leaves the
|
|
6081
7056
|
+ // recorded outputs stamps to verify them, as without one.
|
|
6082
7057
|
+ const matches = await this.daemon.orWithoutDaemon(() => this.daemon.outputsHashesMatchBatch(tasks), () => (0, outputs_stamp_1.outputsStampsMatch)(tasks));
|
|
7058
|
+
+ // The daemon matches the hash it recorded of what a run or restore left, so a record of no files matched
|
|
7059
|
+
+ // outputs that were never there again. A hit keeps outputs only where the workspace holds them, as the
|
|
7060
|
+
+ // stamps answer without a daemon (outputs-stamp.js).
|
|
7061
|
+
+ const present = (0, native_1.getFilesForOutputsBatch)(workspace_root_1.workspaceRoot, tasks.map((task) => task.outputs));
|
|
6083
7062
|
for (let i = 0; i < tasks.length; i++) {
|
|
6084
|
-
|
|
7063
|
+
- resultMap.set(tasks[i].hash, !matches[i]);
|
|
7064
|
+
+ resultMap.set(tasks[i].hash, !matches[i] || present[i].length === 0);
|
|
6085
7065
|
}
|
|
6086
7066
|
}
|
|
6087
7067
|
else {
|
|
@@ -6106,7 +7086,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
6106
7086
|
}
|
|
6107
7087
|
}
|
|
6108
7088
|
// endregion utils
|
|
6109
|
-
@@ -2208,6 +
|
|
7089
|
+
@@ -2208,6 +2313,8 @@ class TaskOrchestrator {
|
|
6110
7090
|
// Waiters must not sit out a probe once the run is stopping
|
|
6111
7091
|
this.abortAllReadiness();
|
|
6112
7092
|
this.readySignal?.close();
|
|
@@ -6115,7 +7095,7 @@ index 9a17f88be6502a302c5f5eab71df646a2f87851c..df1b06c7369aea573df06a3a3d8afd99
|
|
|
6115
7095
|
// Mark all running tasks for intentional stop
|
|
6116
7096
|
const reason = this.stopRequested ? 'interrupted' : 'fulfilled';
|
|
6117
7097
|
for (const entry of this.runningContinuousTasks.values()) {
|
|
6118
|
-
@@ -2277,6 +
|
|
7098
|
+
@@ -2277,6 +2384,7 @@ class TaskOrchestrator {
|
|
6119
7099
|
if (this.stopRequested)
|
|
6120
7100
|
return;
|
|
6121
7101
|
this.stopRequested = true;
|
|
@@ -6513,6 +7493,72 @@ index e654d8c832c5275a2aaa5015887db9167392a694..3e8af252980e6fa141a4af35a51b0681
|
|
|
6513
7493
|
+ }
|
|
6514
7494
|
+ return paths;
|
|
6515
7495
|
+}
|
|
7496
|
+
diff --git a/dist/src/utils/child-process.d.ts b/dist/src/utils/child-process.d.ts
|
|
7497
|
+
index d68999b0b603795bbbc4eb6ef916a8ae008e59ce..4ec8ff6292f811b2d12091250d275e6fa68062a8 100644
|
|
7498
|
+
--- a/dist/src/utils/child-process.d.ts
|
|
7499
|
+
+++ b/dist/src/utils/child-process.d.ts
|
|
7500
|
+
@@ -1,4 +1,4 @@
|
|
7501
|
+
-import { type ExecOptions, type ExecSyncOptions, type SpawnSyncOptions } from 'child_process';
|
|
7502
|
+
+import { type ChildProcess as NodeChildProcess, type ExecOptions, type ExecSyncOptions, type SpawnSyncOptions } from 'child_process';
|
|
7503
|
+
import { PackageManagerCommands } from './package-manager';
|
|
7504
|
+
import { ChildProcess } from '../native';
|
|
7505
|
+
export declare function getRunNxBaseCommand(packageManagerCommand?: PackageManagerCommands, cwd?: string): string;
|
|
7506
|
+
@@ -41,6 +41,13 @@ export declare function runNxAsync(cmd: string, options?: ExecOptions & {
|
|
7507
|
+
silent?: boolean;
|
|
7508
|
+
packageManagerCommand?: PackageManagerCommands;
|
|
7509
|
+
}): Promise<void>;
|
|
7510
|
+
+export declare function hasExited(child: NodeChildProcess): boolean;
|
|
7511
|
+
+/**
|
|
7512
|
+
+ * Settles once `child`'s stdio has closed, which Node reports after 'exit'.
|
|
7513
|
+
+ * Call it at spawn time: a 'close' emitted before the call is missed. Gives up
|
|
7514
|
+
+ * 1s after 'exit', since a descendant can keep the pipes open indefinitely.
|
|
7515
|
+
+ */
|
|
7516
|
+
+export declare function whenStdioClosed(child: NodeChildProcess): Promise<void>;
|
|
7517
|
+
export declare class PseudoTtyProcess {
|
|
7518
|
+
private childProcess;
|
|
7519
|
+
isAlive: boolean;
|
|
7520
|
+
diff --git a/dist/src/utils/child-process.js b/dist/src/utils/child-process.js
|
|
7521
|
+
index fc523cf236b7973e2f4e3f65d042a40f5fda40b3..6eb3daf7dc6640b8b7c45cea97d62aee2163c0b7 100644
|
|
7522
|
+
--- a/dist/src/utils/child-process.js
|
|
7523
|
+
+++ b/dist/src/utils/child-process.js
|
|
7524
|
+
@@ -7,6 +7,8 @@ exports.readInstalledNxBin = readInstalledNxBin;
|
|
7525
|
+
exports.runNxArgvSync = runNxArgvSync;
|
|
7526
|
+
exports.runNxSync = runNxSync;
|
|
7527
|
+
exports.runNxAsync = runNxAsync;
|
|
7528
|
+
+exports.hasExited = hasExited;
|
|
7529
|
+
+exports.whenStdioClosed = whenStdioClosed;
|
|
7530
|
+
const child_process_1 = require("child_process");
|
|
7531
|
+
const fs_1 = require("fs");
|
|
7532
|
+
const path_1 = require("path");
|
|
7533
|
+
@@ -160,6 +162,28 @@ async function runNxAsync(cmd, options) {
|
|
7534
|
+
}
|
|
7535
|
+
});
|
|
7536
|
+
}
|
|
7537
|
+
+function hasExited(child) {
|
|
7538
|
+
+ return child.exitCode !== null || child.signalCode !== null;
|
|
7539
|
+
+}
|
|
7540
|
+
+/**
|
|
7541
|
+
+ * Settles once `child`'s stdio has closed, which Node reports after 'exit'.
|
|
7542
|
+
+ * Call it at spawn time: a 'close' emitted before the call is missed. Gives up
|
|
7543
|
+
+ * 1s after 'exit', since a descendant can keep the pipes open indefinitely.
|
|
7544
|
+
+ */
|
|
7545
|
+
+function whenStdioClosed(child) {
|
|
7546
|
+
+ return new Promise((resolve) => {
|
|
7547
|
+
+ let timeout;
|
|
7548
|
+
+ child.once('close', () => {
|
|
7549
|
+
+ clearTimeout(timeout);
|
|
7550
|
+
+ resolve();
|
|
7551
|
+
+ });
|
|
7552
|
+
+ child.once('exit', () => {
|
|
7553
|
+
+ // Node runs expired timers before it reads the pipes, so a blocked event
|
|
7554
|
+
+ // loop would otherwise give up on output that is already there.
|
|
7555
|
+
+ timeout = setTimeout(() => setImmediate(resolve), 1000);
|
|
7556
|
+
+ });
|
|
7557
|
+
+ });
|
|
7558
|
+
+}
|
|
7559
|
+
class PseudoTtyProcess {
|
|
7560
|
+
constructor(childProcess) {
|
|
7561
|
+
this.childProcess = childProcess;
|
|
6516
7562
|
diff --git a/dist/src/utils/installed-nx-version.js b/dist/src/utils/installed-nx-version.js
|
|
6517
7563
|
index 15a5d36aa9116f7b5ddcadbbeca9dccb7cc7fe45..70cd1b78afb4c54e257c7eec99014a9b139c1293 100644
|
|
6518
7564
|
--- a/dist/src/utils/installed-nx-version.js
|