@smoothbricks/nx-plugin 0.4.28 → 0.4.29

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.
Files changed (124) hide show
  1. package/README.md +203 -83
  2. package/dist/bounded-test-policy.d.ts +10 -3
  3. package/dist/bounded-test-policy.d.ts.map +1 -1
  4. package/dist/bounded-test-policy.js +19 -25
  5. package/dist/cargo-closure-input.d.ts +12 -0
  6. package/dist/cargo-closure-input.d.ts.map +1 -1
  7. package/dist/cargo-closure-input.js +29 -7
  8. package/dist/cargo-source-hash.d.ts.map +1 -1
  9. package/dist/cargo-source-hash.js +42 -19
  10. package/dist/ensure-built-receipt.d.ts +34 -6
  11. package/dist/ensure-built-receipt.d.ts.map +1 -1
  12. package/dist/ensure-built-receipt.js +265 -159
  13. package/dist/ensure-built-witness.d.ts +27 -2
  14. package/dist/ensure-built-witness.d.ts.map +1 -1
  15. package/dist/ensure-built-witness.js +2176 -15
  16. package/dist/ensure-built.d.ts +99 -1
  17. package/dist/ensure-built.d.ts.map +1 -1
  18. package/dist/ensure-built.js +34 -53
  19. package/dist/executors/bounded-exec/cpu-pool.d.ts +16 -5
  20. package/dist/executors/bounded-exec/cpu-pool.d.ts.map +1 -1
  21. package/dist/executors/bounded-exec/cpu-pool.js +43 -19
  22. package/dist/executors/bounded-exec/executor.d.ts +11 -2
  23. package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
  24. package/dist/executors/bounded-exec/executor.js +139 -39
  25. package/dist/executors/bounded-exec/ram-temp.d.ts +17 -11
  26. package/dist/executors/bounded-exec/ram-temp.d.ts.map +1 -1
  27. package/dist/executors/bounded-exec/ram-temp.js +27 -13
  28. package/dist/generators/bun-test-tracing/generator.js +2 -2
  29. package/dist/graph-input-contract.d.ts +98 -0
  30. package/dist/graph-input-contract.d.ts.map +1 -0
  31. package/dist/graph-input-contract.js +624 -0
  32. package/dist/index.d.ts +12 -5
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +17 -3
  35. package/dist/managed-files/ci-workflow.d.ts.map +1 -1
  36. package/dist/managed-files/ci-workflow.js +5 -2
  37. package/dist/managed-files/publish-workflow.d.ts +11 -1
  38. package/dist/managed-files/publish-workflow.d.ts.map +1 -1
  39. package/dist/producer-receipts.d.ts +19 -0
  40. package/dist/producer-receipts.d.ts.map +1 -0
  41. package/dist/producer-receipts.js +921 -0
  42. package/dist/testing.d.ts +8 -0
  43. package/dist/testing.d.ts.map +1 -1
  44. package/dist/testing.js +58 -0
  45. package/managed/raw/patches/nx@23.2.1.patch +328 -50
  46. package/managed/raw/tooling/direnv/developer-links.ts +147 -21
  47. package/managed/raw/tooling/direnv/devenv.smoo.nix +7 -7
  48. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +14 -5
  49. package/managed/raw/tooling/direnv/linked-snapshots.ts +206 -40
  50. package/managed/raw/tooling/direnv/repo-path +15 -2
  51. package/managed/raw/tooling/direnv/setup-environment.ts +179 -114
  52. package/managed/templates/github/actions/cache-node-modules/action.yml +9 -0
  53. package/managed/templates/github/actions/setup-devenv/action.yml +63 -7
  54. package/nextest.toml +1 -1
  55. package/package.json +11 -6
  56. package/src/__tests__/fixture-nx-env.ts +7 -0
  57. package/src/__tests__/owned-installation.ts +174 -0
  58. package/src/bin/smoo-nx-bound-failures.test.ts +1 -1
  59. package/src/bounded-test-policy.test.ts +36 -22
  60. package/src/bounded-test-policy.ts +19 -27
  61. package/src/bun-bootstrap.test.ts +1 -1
  62. package/src/cargo-closure-input.test.ts +60 -11
  63. package/src/cargo-closure-input.ts +28 -6
  64. package/src/cargo-resolve-cache.test.ts +140 -25
  65. package/src/cargo-source-hash.test.ts +78 -3
  66. package/src/cargo-source-hash.ts +48 -30
  67. package/src/cross-check-policy.test.ts +2 -2
  68. package/src/ensure-built-receipt.test.ts +111 -16
  69. package/src/ensure-built-receipt.ts +251 -149
  70. package/src/ensure-built-witness.test.ts +197 -13
  71. package/src/ensure-built-witness.ts +187 -15
  72. package/src/ensure-built.test.ts +156 -102
  73. package/src/ensure-built.ts +114 -64
  74. package/src/executors/bounded-exec/cpu-pool.test.ts +116 -32
  75. package/src/executors/bounded-exec/cpu-pool.ts +55 -17
  76. package/src/executors/bounded-exec/cpu-tokens.test.ts +2 -2
  77. package/src/executors/bounded-exec/executor-host.test.ts +51 -41
  78. package/src/executors/bounded-exec/executor.test.ts +155 -35
  79. package/src/executors/bounded-exec/executor.ts +156 -45
  80. package/src/executors/bounded-exec/progress.test.ts +1 -1
  81. package/src/executors/bounded-exec/ram-temp-host.test.ts +46 -17
  82. package/src/executors/bounded-exec/ram-temp.test.ts +65 -3
  83. package/src/executors/bounded-exec/ram-temp.ts +32 -16
  84. package/src/executors/bounded-exec/verdict.test.ts +17 -12
  85. package/src/generators/bounded-test-targets/generator.test.ts +1 -3
  86. package/src/generators/bun-test-tracing/generator.test.ts +2 -2
  87. package/src/generators/bun-test-tracing/generator.ts +2 -2
  88. package/src/graph-input-contract.test.ts +371 -0
  89. package/src/graph-input-contract.ts +605 -0
  90. package/src/index.test.ts +3 -3
  91. package/src/index.ts +24 -3
  92. package/src/linked-snapshots.nx.test.ts +112 -30
  93. package/src/managed-files/ci-workflow.ts +5 -2
  94. package/src/managed-files/publish-workflow.ts +12 -1
  95. package/src/managed-files/repo-path.test.ts +44 -1
  96. package/src/managed-files/setup-devenv-free-disk.test.ts +95 -0
  97. package/src/nextest-code-bound.test.ts +23 -17
  98. package/src/nextest-partitions.test.ts +7 -1
  99. package/src/nx-cache-restore-mtime.test.ts +2 -2
  100. package/src/nx-daemon-claim.test.ts +5 -5
  101. package/src/nx-daemon-idle-cpu.test.ts +0 -1
  102. package/src/nx-daemon-idle-policy.test.ts +56 -0
  103. package/src/nx-daemon-ignore-files.test.ts +2 -2
  104. package/src/nx-daemon-validity.test.ts +31 -9
  105. package/src/nx-dot-input-policy.test.ts +5 -5
  106. package/src/nx-files-archive-racy.test.ts +1 -1
  107. package/src/nx-incomplete-run-summary.test.ts +1 -1
  108. package/src/nx-plugin-load-errors.test.ts +2 -2
  109. package/src/nx-project-graph-errors.test.ts +70 -0
  110. package/src/nx-skipped-task-exit.test.ts +2 -2
  111. package/src/nx-store-resolution.test.ts +7 -25
  112. package/src/nx-task-output-lease.test.ts +3 -3
  113. package/src/nx-use-local.test.ts +7 -5
  114. package/src/producer-receipts.test.ts +164 -0
  115. package/src/producer-receipts.ts +631 -0
  116. package/src/runtime-input.test.ts +1 -1
  117. package/src/serial-group-wiring.test.ts +4 -4
  118. package/src/task-results.test.ts +18 -16
  119. package/src/test-timings.test.ts +2 -2
  120. package/src/testing.test.ts +5 -5
  121. package/src/testing.ts +59 -0
  122. package/src/typecheck-test-policy.test.ts +1 -1
  123. package/src/typescript-resolution.test.ts +76 -0
  124. package/test-timings.json +5 -0
package/dist/testing.d.ts CHANGED
@@ -24,6 +24,14 @@ export declare function terminate(pid: number, signal?: NodeJS.Signals): void;
24
24
  export declare function awaitExit(processes: readonly ProcessEntry[], owner: string, timeoutMs?: number): Promise<void>;
25
25
  /** Every process of this user whose working directory is `root` or lies beneath it, deleted or not. */
26
26
  export declare function pidsWorkingIn(root: string): Promise<number[]>;
27
+ /**
28
+ * Every process of this user started with `TMPDIR` set to `root` or beneath it. Such a process
29
+ * writes there whatever its working directory: a ttsc plugin build copies its Go sources into
30
+ * `$TMPDIR` from a process working in its project, and Node and Bun write their compile cache
31
+ * there on the way out. The environment is the one the process was started with, which is the
32
+ * one its children inherit unless it changed it for them.
33
+ */
34
+ export declare function pidsWithTempIn(root: string): Promise<number[]>;
27
35
  /**
28
36
  * The Nx daemon `workspace` runs, the daemon first, then every process it
29
37
  * started. Empty when the workspace records no daemon or the recorded one is
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AA+CA,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,IAAI,EAAE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;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASnF;AA0DD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBxF"}
package/dist/testing.js CHANGED
@@ -176,6 +176,64 @@ export async function pidsWorkingIn(root) {
176
176
  throw new Error(`No working-directory scan for ${process.platform}`);
177
177
  }
178
178
  }
179
+ /**
180
+ * Every process of this user started with `TMPDIR` set to `root` or beneath it. Such a process
181
+ * writes there whatever its working directory: a ttsc plugin build copies its Go sources into
182
+ * `$TMPDIR` from a process working in its project, and Node and Bun write their compile cache
183
+ * there on the way out. The environment is the one the process was started with, which is the
184
+ * one its children inherit unless it changed it for them.
185
+ */
186
+ export async function pidsWithTempIn(root) {
187
+ // The value as it follows `TMPDIR=`: `root` itself, with or without its trailing slash, or below it.
188
+ const names = (value) => value.startsWith(root) && ['', '/', ' '].includes(value.charAt(root.length));
189
+ switch (process.platform) {
190
+ case 'linux': {
191
+ const found = [];
192
+ for (const pid of (await readdir('/proc')).filter((name) => /^\d+$/.test(name))) {
193
+ const environ = await readFile(`/proc/${pid}/environ`, 'utf8').catch((error) => {
194
+ // Another user's process, or one that exited since the listing.
195
+ if (errorCode(error) === 'EACCES' || errorCode(error) === 'ENOENT' || errorCode(error) === 'ESRCH') {
196
+ return null;
197
+ }
198
+ throw error;
199
+ });
200
+ const entry = environ?.split('\0').find((variable) => variable.startsWith('TMPDIR='));
201
+ if (entry !== undefined && names(entry.slice('TMPDIR='.length))) {
202
+ found.push(Number(pid));
203
+ }
204
+ }
205
+ return found;
206
+ }
207
+ case 'darwin': {
208
+ // `ps -E` follows each command line with the environment it was started with, as words
209
+ // separated by spaces, and only for this user's processes. A word `TMPDIR=<root>` is matched
210
+ // with what follows it in that word, so a root containing a space is still found whole. An
211
+ // argument spelled `TMPDIR=<root>` names the same directory and counts too: an `env` that
212
+ // sets it is about to run something there. `/bin/ps` by path: a procps `ps` has no `-E`.
213
+ const { stdout } = await run('/bin/ps', ['-E', '-ww', '-U', String(userInfo().uid), '-o', 'pid=,command='], {
214
+ maxBuffer: 256 * 1024 * 1024,
215
+ });
216
+ const token = ` TMPDIR=${root}`;
217
+ const found = [];
218
+ for (const line of stdout.split('\n')) {
219
+ const row = /^\s*(\d+) (.*)$/.exec(line);
220
+ if (row === null) {
221
+ continue;
222
+ }
223
+ const words = ` ${row[2]}`;
224
+ for (let at = words.indexOf(token); at !== -1; at = words.indexOf(token, at + 1)) {
225
+ if (names(words.slice(at + ' TMPDIR='.length))) {
226
+ found.push(Number(row[1]));
227
+ break;
228
+ }
229
+ }
230
+ }
231
+ return found;
232
+ }
233
+ default:
234
+ throw new Error(`No TMPDIR scan for ${process.platform}`);
235
+ }
236
+ }
179
237
  /**
180
238
  * The Nx daemon `workspace` runs, the daemon first, then every process it
181
239
  * started. Empty when the workspace records no daemon or the recorded one is
@@ -343,7 +343,7 @@ index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..c552b4b252c2d0496312ddb6ff481699
343
343
  flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
344
344
  getRegisteredSyncGenerators(): Promise<{
345
345
  diff --git a/dist/src/daemon/client/client.js b/dist/src/daemon/client/client.js
346
- index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a0389a0c54c40d43cf863b899bf49193d2918332 100644
346
+ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..31fcb14fbf3811f0e1c545791026e5a6a3133399 100644
347
347
  --- a/dist/src/daemon/client/client.js
348
348
  +++ b/dist/src/daemon/client/client.js
349
349
  @@ -40,7 +40,6 @@ const nx_console_1 = require("../message-types/nx-console");
@@ -382,7 +382,54 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a0389a0c54c40d43cf863b899bf49193
382
382
  getSyncGeneratorChanges(generators) {
383
383
  const message = {
384
384
  type: get_sync_generator_changes_1.GET_SYNC_GENERATOR_CHANGES,
385
- @@ -1132,8 +1110,11 @@ class DaemonClient {
385
+ @@ -831,13 +809,24 @@ class DaemonClient {
386
+ }
387
+ }
388
+ async sendToDaemonViaQueue(messageToDaemon, parser) {
389
+ - return this.queue.sendToQueue(async () => {
390
+ - // Set currentSpinner inside the queued function so it's only
391
+ - // active while this specific message is in flight — preventing
392
+ - // concurrent callers from overwriting each other's spinner
393
+ - // reference before their turn arrives.
394
+ - return await this.sendMessageToDaemon(messageToDaemon, parser);
395
+ - });
396
+ + try {
397
+ + return await this.queue.sendToQueue(async () => {
398
+ + // Set currentSpinner inside the queued function so it's only
399
+ + // active while this specific message is in flight — preventing
400
+ + // concurrent callers from overwriting each other's spinner
401
+ + // reference before their turn arrives.
402
+ + return await this.sendMessageToDaemon(messageToDaemon, parser);
403
+ + });
404
+ + }
405
+ + finally {
406
+ + // A plugin worker is a client of its daemon only while it waits on a
407
+ + // reply. The daemon keeps a worker with graph hooks alive, and an open
408
+ + // request connection keeps the daemon from its idle stop, so a worker
409
+ + // that stayed connected would keep its own host alive forever.
410
+ + if (global.NX_PLUGIN_WORKER && this.queue.isEmpty()) {
411
+ + this.reset();
412
+ + }
413
+ + }
414
+ }
415
+ setUpConnection() {
416
+ const socketPath = this.getSocketPath();
417
+ @@ -846,7 +835,13 @@ class DaemonClient {
418
+ // sendMessageToDaemon method uses a keep-alive setTimeout to
419
+ // explicitly hold the event loop open while awaiting a response.
420
+ socket.unref();
421
+ - this.socketMessenger = new daemon_socket_messenger_1.DaemonSocketMessenger(socket).listen((message) => this.handleMessage(message), () => {
422
+ + const messenger = new daemon_socket_messenger_1.DaemonSocketMessenger(socket);
423
+ + this.socketMessenger = messenger.listen((message) => this.handleMessage(message), () => {
424
+ + // A connection reset() already let go says nothing about the current
425
+ + // one, which may be carrying a request by the time this close arrives.
426
+ + if (this.socketMessenger !== messenger) {
427
+ + return;
428
+ + }
429
+ // it's ok for the daemon to terminate if the client doesn't wait on
430
+ // any messages from the daemon
431
+ if (this.queue.isEmpty()) {
432
+ @@ -1132,8 +1127,11 @@ class DaemonClient {
386
433
  */
387
434
  const { available, refusal: polled } = await this.waitForServerToBeAvailable({ ignoreVersionMismatch: true });
388
435
  if (available) {
@@ -631,10 +678,10 @@ index c2a2f8f70fe71940e47c97931c5925bac1fbd480..39582a8fc342ae59decd3d4ca25179f2
631
678
  // Bump generation synchronously so any in-flight compute fails its
632
679
  diff --git a/dist/src/daemon/server/restart-checks.d.ts b/dist/src/daemon/server/restart-checks.d.ts
633
680
  new file mode 100644
634
- index 0000000000000000000000000000000000000000..65660f0d5f7789d64ad26b0a9644f23949e79831
681
+ index 0000000000000000000000000000000000000000..2a76dce933112854e34d61a44aa90b7c4e1d34e9
635
682
  --- /dev/null
636
683
  +++ b/dist/src/daemon/server/restart-checks.d.ts
637
- @@ -0,0 +1,9 @@
684
+ @@ -0,0 +1,10 @@
638
685
  +import type { Server, Socket } from 'net';
639
686
  +import type { WatchEvent } from '../../native';
640
687
  +export declare const DAEMON_VALIDITY_SAFETY_INTERVAL_MS = 5000;
@@ -644,12 +691,13 @@ index 0000000000000000000000000000000000000000..65660f0d5f7789d64ad26b0a9644f239
644
691
  +export declare function restartDaemonIfLockFilesChanged(paths: string[]): boolean;
645
692
  +export declare function stopDaemonIfReplaced(events: WatchEvent[]): boolean;
646
693
  +export declare function stopDaemonIfOutdated(): boolean;
694
+ +export declare function stopDaemonIfWorkspaceGone(): boolean;
647
695
  diff --git a/dist/src/daemon/server/restart-checks.js b/dist/src/daemon/server/restart-checks.js
648
696
  new file mode 100644
649
- index 0000000000000000000000000000000000000000..e45f9d2c918a1d33b6ebb29be76dfb2eecd37b45
697
+ index 0000000000000000000000000000000000000000..6adb712340b154dcabb7570bc1b4c586f3416cdf
650
698
  --- /dev/null
651
699
  +++ b/dist/src/daemon/server/restart-checks.js
652
- @@ -0,0 +1,113 @@
700
+ @@ -0,0 +1,127 @@
653
701
  +"use strict";
654
702
  +Object.defineProperty(exports, "__esModule", { value: true });
655
703
  +exports.relativeServerProcess = exports.DAEMON_VALIDITY_SAFETY_INTERVAL_MS = void 0;
@@ -658,6 +706,7 @@ index 0000000000000000000000000000000000000000..e45f9d2c918a1d33b6ebb29be76dfb2e
658
706
  +exports.restartDaemonIfLockFilesChanged = restartDaemonIfLockFilesChanged;
659
707
  +exports.stopDaemonIfReplaced = stopDaemonIfReplaced;
660
708
  +exports.stopDaemonIfOutdated = stopDaemonIfOutdated;
709
+ +exports.stopDaemonIfWorkspaceGone = stopDaemonIfWorkspaceGone;
661
710
  +const fs_1 = require("fs");
662
711
  +const path_1 = require("path");
663
712
  +const file_hasher_1 = require("../../hasher/file-hasher");
@@ -723,10 +772,23 @@ index 0000000000000000000000000000000000000000..e45f9d2c918a1d33b6ebb29be76dfb2e
723
772
  + }
724
773
  + return replaced;
725
774
  +}
775
+ +const nxJson = (0, path_1.join)(workspace_root_1.workspaceRoot, 'nx.json');
776
+ +// Nx 23.2.1's native file worker takes an empty file map for one it has not
777
+ +// filled yet and waits for it (`FilesWorker::get_files`), so the first read of
778
+ +// a workspace whose files have all gone blocks the daemon's only thread for
779
+ +// good: no timer, request or SIGTERM handler runs again, and only SIGKILL ends
780
+ +// it. nx.json is one of those files, and without it this is no Nx workspace,
781
+ +// so its absence stops the daemon before it reads the workspace again.
782
+ +function stopDaemonIfWorkspaceGone() {
783
+ + if (terminating) return true;
784
+ + if ((0, fs_1.existsSync)(nxJson)) return false;
785
+ + stopDaemon(`its workspace ${workspace_root_1.workspaceRoot} has no nx.json any more`);
786
+ + return true;
787
+ +}
726
788
  +// Once per request, including long-lived sockets, and on the slow safety poll.
727
789
  +// The socket guard uses the inode captured at bind, never a client's environment.
728
790
  +function stopDaemonIfOutdated() {
729
- + if (terminating) return true;
791
+ + if (stopDaemonIfWorkspaceGone()) return true;
730
792
  + if (isReplaced()) {
731
793
  + stopDaemon('this process is no longer the current daemon (native)');
732
794
  + return true;
@@ -764,7 +826,7 @@ index 0000000000000000000000000000000000000000..e45f9d2c918a1d33b6ebb29be76dfb2e
764
826
  + (0, shutdown_utils_1.handleServerProcessTerminationWithRestart)({ server: daemon.server, reason, sockets: daemon.sockets });
765
827
  +}
766
828
  diff --git a/dist/src/daemon/server/server.js b/dist/src/daemon/server/server.js
767
- index b1c143e244efd435b28642ed86e999d6c86f7d94..9939d13d2845b63af8dfdfbba08a01d3832fe34d 100644
829
+ index b1c143e244efd435b28642ed86e999d6c86f7d94..5f1157fd3e37afc8ef739a8adce78a2b472e08af 100644
768
830
  --- a/dist/src/daemon/server/server.js
769
831
  +++ b/dist/src/daemon/server/server.js
770
832
  @@ -7,17 +7,13 @@ const fs_1 = require("fs");
@@ -898,7 +960,19 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..9939d13d2845b63af8dfdfbba08a01d3
898
960
  /**
899
961
  * When applicable files in the workspaces are changed (created, updated, deleted),
900
962
  * we need to recompute the cached serialized project graph so that it is readily
901
- @@ -348,7 +312,43 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
963
+ @@ -339,6 +303,11 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
964
+ return;
965
+ }
966
+ logger_1.serverLogger.watcherLog((0, watcher_1.convertChangeEventsToLogMessage)(changeEvents));
967
+ + // Applying a batch that deleted the last file would leave the next read
968
+ + // of the workspace blocked for good (restart-checks.js).
969
+ + if ((0, restart_checks_1.stopDaemonIfWorkspaceGone)()) {
970
+ + return;
971
+ + }
972
+ (0, route_workspace_changes_1.routeWorkspaceChanges)(changeEvents);
973
+ }
974
+ catch (err) {
975
+ @@ -348,7 +317,43 @@ const handleWorkspaceChanges = async (err, changeEvents) => {
902
976
  (0, file_watcher_sockets_1.notifyFileWatcherSocketsOfError)(err);
903
977
  }
904
978
  };
@@ -942,7 +1016,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..9939d13d2845b63af8dfdfbba08a01d3
942
1016
  // Watch before scan: a file written during boot must be visible to the
943
1017
  // watcher or the scan below. Scan-first left a blind window where such
944
1018
  // files stayed invisible to both until an unrelated change arrived.
945
- @@ -359,54 +359,21 @@ async function startServer() {
1019
+ @@ -359,54 +364,21 @@ async function startServer() {
946
1020
  (0, workspace_context_1.setupWorkspaceContext)(workspace_root_1.workspaceRoot);
947
1021
  // Initialize analytics for daemon process
948
1022
  await (0, analytics_1.startAnalytics)();
@@ -1002,7 +1076,7 @@ index b1c143e244efd435b28642ed86e999d6c86f7d94..9939d13d2845b63af8dfdfbba08a01d3
1002
1076
  return new Promise(async (resolve, reject) => {
1003
1077
  // `listen` reports a failed bind asynchronously on the server, which the
1004
1078
  // try below cannot catch — without this an EACCES became an uncaught
1005
- @@ -432,8 +399,7 @@ async function startServer() {
1079
+ @@ -432,8 +404,7 @@ async function startServer() {
1006
1080
  // Best effort; the 0700 socket directory is the primary control.
1007
1081
  }
1008
1082
  }
@@ -1504,6 +1578,138 @@ index 28c9655c4612dcc85a881816f172dce98642bb0c..ea65f019024da507dd81f4ace1202091
1504
1578
  }
1505
1579
  catch (e) {
1506
1580
  // we need to include the workspace validity errors in the final error
1581
+ diff --git a/dist/src/project-graph/error-types.d.ts b/dist/src/project-graph/error-types.d.ts
1582
+ index 46d9dfad0c1027d000776a78c3afb87e713ffa97..0eff844129dad8f03eb6ab5f8b57b4d49718b1f9 100644
1583
+ --- a/dist/src/project-graph/error-types.d.ts
1584
+ +++ b/dist/src/project-graph/error-types.d.ts
1585
+ @@ -66,6 +66,12 @@ export declare class ProjectConfigurationsError extends Error {
1586
+ constructor(errors: Array<MergeNodesError | AggregateCreateNodesError | ProjectsWithNoNameError | MultipleProjectsWithSameNameError | WorkspaceValidityError>, partialProjectConfigurationsResult: ConfigurationResult);
1587
+ }
1588
+ export declare function isProjectConfigurationsError(e: unknown): e is ProjectConfigurationsError;
1589
+ +export declare function formatErrorMessages(error: unknown): string;
1590
+ +export declare function formatProjectGraphError(error: ProjectGraphError | ProjectConfigurationsError, isVerbose: boolean): {
1591
+ + title: string;
1592
+ + bodyLines: string[];
1593
+ +};
1594
+ +export declare function formatErrorStackAndCause(error: Error): string;
1595
+ /**
1596
+ * This error should be thrown when a `createNodesV2` function hits a recoverable error.
1597
+ * It allows Nx to recieve partial results and continue processing for better UX.
1598
+ diff --git a/dist/src/project-graph/error-types.js b/dist/src/project-graph/error-types.js
1599
+ index 1ce005430eef99e12234a5471c9761a2f7acc905..45d4d373853eebea7325450c36148e9985f74789 100644
1600
+ --- a/dist/src/project-graph/error-types.js
1601
+ +++ b/dist/src/project-graph/error-types.js
1602
+ @@ -13,6 +13,9 @@ exports.isAggregateProjectGraphError = isAggregateProjectGraphError;
1603
+ exports.isCreateMetadataError = isCreateMetadataError;
1604
+ exports.isAggregateCreateNodesError = isAggregateCreateNodesError;
1605
+ exports.isMergeNodesError = isMergeNodesError;
1606
+ +exports.formatErrorMessages = formatErrorMessages;
1607
+ +exports.formatProjectGraphError = formatProjectGraphError;
1608
+ +exports.formatErrorStackAndCause = formatErrorStackAndCause;
1609
+ const tslib_1 = require("tslib");
1610
+ class StaleProjectGraphCacheError extends Error {
1611
+ constructor() {
1612
+ @@ -333,9 +336,10 @@ function formatAggregateCreateNodesError(error, pluginName) {
1613
+ errorStackLines.push(` - ${file}:`);
1614
+ }
1615
+ for (const e of errors) {
1616
+ - const messageLines = e.message.split('\n');
1617
+ - // Errors deserialized from a plugin worker may arrive without a stack.
1618
+ - const stackLines = (e.stack ?? e.message).split('\n');
1619
+ + const messageLines = formatErrorMessages(e).split('\n');
1620
+ + // Errors deserialized from a plugin worker may arrive without a
1621
+ + // stack; formatErrorStackAndCause falls back to the message.
1622
+ + const stackLines = formatErrorStackAndCause(e).split('\n');
1623
+ if (file) {
1624
+ errorBodyLines.push(...messageLines.map((line) => ` ${line}`));
1625
+ errorStackLines.push(...stackLines.map((line) => ` ${line}`));
1626
+ @@ -475,10 +479,81 @@ function indentString(str, indent) {
1627
+ .map((line) => ' '.repeat(indent) + line)
1628
+ .join('\n'));
1629
+ }
1630
+ +// Every message an error carries, without stacks: its own, its `cause` chain
1631
+ +// and its nested `errors` (AggregateCreateNodesError entries are [file, error]
1632
+ +// pairs). An AggregateCreateNodesError's message already lists its entries
1633
+ +// (formatAggregateCreateNodesError), so they are not repeated. A shared error
1634
+ +// in separate branches stays visible in each; a circular one is named.
1635
+ +function formatErrorMessages(error, ancestors = new Set()) {
1636
+ + const isObject = error !== null && typeof error === 'object';
1637
+ + if (isObject) {
1638
+ + if (ancestors.has(error)) {
1639
+ + return '[Circular error]';
1640
+ + }
1641
+ + ancestors.add(error);
1642
+ + }
1643
+ + let message = Array.isArray(error) ? '' : String(error?.message ?? error);
1644
+ + if (error?.cause !== undefined) {
1645
+ + message += `\nCaused by: ${formatErrorMessages(error.cause, ancestors)}`;
1646
+ + }
1647
+ + const nestedErrors = Array.isArray(error)
1648
+ + ? error
1649
+ + : isObject && isAggregateCreateNodesError(error)
1650
+ + ? undefined
1651
+ + : error?.errors;
1652
+ + if (Array.isArray(nestedErrors)) {
1653
+ + for (const nested of nestedErrors) {
1654
+ + message += `${message ? '\n' : ''}${formatErrorMessages(nested, ancestors)}`;
1655
+ + }
1656
+ + }
1657
+ + if (isObject) {
1658
+ + ancestors.delete(error);
1659
+ + }
1660
+ + return message;
1661
+ +}
1662
+ +// nrwl/nx#37103: without --verbose, name every underlying error (messages and
1663
+ +// causes) instead of the bare "Failed to process project graph." headline.
1664
+ +function formatProjectGraphError(error, isVerbose) {
1665
+ + const errors = isProjectConfigurationsError(error)
1666
+ + ? error.errors
1667
+ + : error.getErrors();
1668
+ + let title = error.message;
1669
+ + if (error.cause &&
1670
+ + typeof error.cause === 'object' &&
1671
+ + 'message' in error.cause) {
1672
+ + title += ' ' + error.cause.message + '.';
1673
+ + }
1674
+ + return {
1675
+ + title,
1676
+ + bodyLines: isVerbose
1677
+ + ? [formatErrorStackAndCause(error)]
1678
+ + : [
1679
+ + ...errors.map((e) => formatErrorMessages(e)),
1680
+ + '',
1681
+ + 'Pass --verbose to see the stacktraces.',
1682
+ + ],
1683
+ + };
1684
+ +}
1685
+ function formatErrorStackAndCause(error) {
1686
+ - const cause = error.cause && error.cause instanceof Error ? error.cause : null;
1687
+ - return (error.stack +
1688
+ - (cause
1689
+ - ? `\nCaused by: \n${indentString(cause.stack ?? cause.message, 2)}`
1690
+ - : ''));
1691
+ + const cause = describeCause(error.cause);
1692
+ + return ((error.stack ?? error.message) +
1693
+ + (cause ? `\nCaused by: \n${indentString(cause, 2)}` : ''));
1694
+ +}
1695
+ +function describeCause(cause) {
1696
+ + if (!cause) {
1697
+ + return null;
1698
+ + }
1699
+ + if (cause instanceof Error) {
1700
+ + return cause.stack ?? cause.message;
1701
+ + }
1702
+ + if (typeof cause === 'object') {
1703
+ + const { stack, message } = cause;
1704
+ + if (typeof stack === 'string') {
1705
+ + return stack;
1706
+ + }
1707
+ + if (typeof message === 'string') {
1708
+ + return message;
1709
+ + }
1710
+ + }
1711
+ + return String(cause);
1712
+ }
1507
1713
  diff --git a/dist/src/project-graph/nx-deps-cache.d.ts b/dist/src/project-graph/nx-deps-cache.d.ts
1508
1714
  index 5bc1e76b319294101cc9b038dc6eb0ad01036b13..baf7908aeb206f1c4e26ed0c8578465d8b510776 100644
1509
1715
  --- a/dist/src/project-graph/nx-deps-cache.d.ts
@@ -1598,61 +1804,36 @@ index a880a6620cd7ac46e4bd189bc2034ce58825769a..ef3c99a115e7114ea78da379316a0478
1598
1804
  })) {
1599
1805
  return true;
1600
1806
  diff --git a/dist/src/project-graph/plugins/get-plugins.js b/dist/src/project-graph/plugins/get-plugins.js
1601
- index df153050063fa81b915d3004d3a87cd397f73b19..7d751ed7b895ea88735361b481c9437339ef7ffa 100644
1807
+ index df153050063fa81b915d3004d3a87cd397f73b19..ddc9b044fd4b74e7d25d95f6f636c1b721a301eb 100644
1602
1808
  --- a/dist/src/project-graph/plugins/get-plugins.js
1603
1809
  +++ b/dist/src/project-graph/plugins/get-plugins.js
1604
- @@ -296,7 +296,7 @@ async function loadDefaultNxPlugins(root = workspace_root_1.workspaceRoot) {
1810
+ @@ -22,6 +22,7 @@ const is_sandbox_1 = require("../../utils/is-sandbox");
1811
+ const native_1 = require("../../native");
1812
+ const output_1 = require("../../utils/output");
1813
+ const transpiler_1 = require("./transpiler");
1814
+ +const error_types_1 = require("../error-types");
1815
+ /**
1816
+ * Stuff for specified NX Plugins.
1817
+ */
1818
+ @@ -296,7 +297,7 @@ async function loadDefaultNxPlugins(root = workspace_root_1.workspaceRoot) {
1605
1819
  fn();
1606
1820
  }
1607
1821
  const errorMessage = errors
1608
1822
  - .map((e) => ` - ${e.pluginName}: ${e.error.message}`)
1609
- + .map((e) => ` - ${e.pluginName}: ${formatPluginLoadError(e.error).replace(/\n/g, '\n ')}`)
1823
+ + .map((e) => ` - ${e.pluginName}: ${(0, error_types_1.formatErrorMessages)(e.error).replace(/\n/g, '\n ')}`)
1610
1824
  .join('\n');
1611
1825
  throw new AggregateError(errors.map((e) => e.error), `Failed to load ${errors.length} default Nx plugin(s):\n${errorMessage}`);
1612
1826
  }
1613
- @@ -361,7 +361,7 @@ async function loadSpecifiedNxPlugins(pluginsConfigurations, root = workspace_ro
1827
+ @@ -361,7 +362,7 @@ async function loadSpecifiedNxPlugins(pluginsConfigurations, root = workspace_ro
1614
1828
  fn();
1615
1829
  }
1616
1830
  const errorMessage = errors
1617
1831
  - .map((e) => ` - ${e.pluginName}: ${e.error.message}`)
1618
- + .map((e) => ` - ${e.pluginName}: ${formatPluginLoadError(e.error).replace(/\n/g, '\n ')}`)
1832
+ + .map((e) => ` - ${e.pluginName}: ${(0, error_types_1.formatErrorMessages)(e.error).replace(/\n/g, '\n ')}`)
1619
1833
  .join('\n');
1620
1834
  throw new AggregateError(errors.map((e) => e.error), `Failed to load ${errors.length} Nx plugin(s):\n${errorMessage}`);
1621
1835
  }
1622
- @@ -376,6 +376,32 @@ async function loadSpecifiedNxPlugins(pluginsConfigurations, root = workspace_ro
1623
- };
1624
- return plugins;
1625
- }
1626
- +// Plugin resolution can wrap configuration errors before a plugin ever runs.
1627
- +// Keep their causes and aggregate entries in the non-verbose diagnostic too.
1628
- +function formatPluginLoadError(error, ancestors = new Set()) {
1629
- + const isObject = error !== null && typeof error === 'object';
1630
- + if (isObject) {
1631
- + if (ancestors.has(error)) {
1632
- + return '[Circular error]';
1633
- + }
1634
- + ancestors.add(error);
1635
- + }
1636
- + let message = Array.isArray(error) ? '' : String(error?.message ?? error);
1637
- + if (error?.cause !== undefined) {
1638
- + message += `\nCaused by: ${formatPluginLoadError(error.cause, ancestors)}`;
1639
- + }
1640
- + // AggregateCreateNodesError entries can be [file, error] pairs.
1641
- + const nestedErrors = Array.isArray(error) ? error : error?.errors;
1642
- + if (Array.isArray(nestedErrors)) {
1643
- + for (const nested of nestedErrors) {
1644
- + message += `${message ? '\n' : ''}${formatPluginLoadError(nested, ancestors)}`;
1645
- + }
1646
- + }
1647
- + if (isObject) {
1648
- + ancestors.delete(error);
1649
- + }
1650
- + return message;
1651
- +}
1652
- function reasonToError(reason) {
1653
- if (reason instanceof Error) {
1654
- return reason;
1655
- @@ -385,6 +411,12 @@ function reasonToError(reason) {
1836
+ @@ -385,6 +386,12 @@ function reasonToError(reason) {
1656
1837
  if ('stack' in reason) {
1657
1838
  error.stack = String(reason.stack);
1658
1839
  }
@@ -1760,6 +1941,26 @@ index 3659fdd1955d56e60cc0158d19ac55d59916d78e..92e6700adfc52a380b3e9e37b655fbc9
1760
1941
  }
1761
1942
  /**
1762
1943
  * Returns the current session count for a phase. Useful for testing.
1944
+ diff --git a/dist/src/project-graph/project-graph.js b/dist/src/project-graph/project-graph.js
1945
+ index a23de7d0f27d7bc222ee09f4904f5d236510d01d..247ed0fe9f7a1a1a3d8d91d0d772763e9068b1be 100644
1946
+ --- a/dist/src/project-graph/project-graph.js
1947
+ +++ b/dist/src/project-graph/project-graph.js
1948
+ @@ -149,14 +149,7 @@ function handleProjectGraphError(opts, e) {
1949
+ if (opts.exitOnError) {
1950
+ const isVerbose = process.env.NX_VERBOSE_LOGGING === 'true';
1951
+ if (e instanceof error_types_1.ProjectGraphError) {
1952
+ - let title = e.message;
1953
+ - const bodyLines = isVerbose
1954
+ - ? [e.stack]
1955
+ - : ['Pass --verbose to see the stacktraces.'];
1956
+ - output_1.output.error({
1957
+ - title,
1958
+ - bodyLines: bodyLines,
1959
+ - });
1960
+ + output_1.output.error((0, error_types_1.formatProjectGraphError)(e, isVerbose));
1961
+ }
1962
+ else if (typeof e.message === 'string') {
1963
+ const lines = e.message.split('\n');
1763
1964
  diff --git a/dist/src/tasks-runner/cache.d.ts b/dist/src/tasks-runner/cache.d.ts
1764
1965
  index 34aa44f81f1df63c5d33e58d8b55d15fcf1d7619..edf41406f465726828fa447bd10d71a49a2ede8a 100644
1765
1966
  --- a/dist/src/tasks-runner/cache.d.ts
@@ -3066,6 +3267,83 @@ index 0000000000000000000000000000000000000000..9f8639b22d29c8a4aca18a0efaec7a26
3066
3267
  + }
3067
3268
  + exports.TaskOutputLeases = TaskOutputLeases;
3068
3269
  +}
3270
+ diff --git a/dist/src/utils/handle-errors.js b/dist/src/utils/handle-errors.js
3271
+ index 41697164fa6d52a98ed5cc95be6b24f64f2ced5b..500aca4f73f366ba2910cdbd93963333310313dd 100644
3272
+ --- a/dist/src/utils/handle-errors.js
3273
+ +++ b/dist/src/utils/handle-errors.js
3274
+ @@ -1,6 +1,7 @@
3275
+ "use strict";
3276
+ Object.defineProperty(exports, "__esModule", { value: true });
3277
+ exports.handleErrors = handleErrors;
3278
+ +const error_types_1 = require("../project-graph/error-types");
3279
+ const logger_1 = require("./logger");
3280
+ const output_1 = require("./output");
3281
+ const handle_import_1 = require("./handle-import");
3282
+ @@ -17,35 +18,9 @@ async function handleErrors(isVerbose, fn) {
3283
+ if (err.constructor.name === 'UnsuccessfulWorkflowExecution') {
3284
+ logger_1.logger.error('The generator workflow failed. See above.');
3285
+ }
3286
+ - else if (err.name === 'ProjectGraphError') {
3287
+ - const projectGraphError = err;
3288
+ - let title = projectGraphError.message;
3289
+ - if (projectGraphError.cause &&
3290
+ - typeof projectGraphError.cause === 'object' &&
3291
+ - 'message' in projectGraphError.cause) {
3292
+ - title += ' ' + projectGraphError.cause.message + '.';
3293
+ - }
3294
+ - output_1.output.error({
3295
+ - title,
3296
+ - bodyLines: isVerbose
3297
+ - ? formatErrorStackAndCause(projectGraphError, isVerbose)
3298
+ - : projectGraphError.getErrors().map((e) => e.message),
3299
+ - });
3300
+ - }
3301
+ - else if (err.name === 'ProjectConfigurationsError') {
3302
+ - const projectConfigurationsError = err;
3303
+ - let title = projectConfigurationsError.message;
3304
+ - if (projectConfigurationsError.cause &&
3305
+ - typeof projectConfigurationsError.cause === 'object' &&
3306
+ - 'message' in projectConfigurationsError.cause) {
3307
+ - title += ' ' + projectConfigurationsError.cause.message + '.';
3308
+ - }
3309
+ - output_1.output.error({
3310
+ - title,
3311
+ - bodyLines: isVerbose
3312
+ - ? formatErrorStackAndCause(projectConfigurationsError, isVerbose)
3313
+ - : projectConfigurationsError.errors.map((e) => e.message),
3314
+ - });
3315
+ + else if (err.name === 'ProjectGraphError' ||
3316
+ + err.name === 'ProjectConfigurationsError') {
3317
+ + output_1.output.error((0, error_types_1.formatProjectGraphError)(err, isVerbose));
3318
+ }
3319
+ else if (err.name === 'MinReleaseAgeViolationError') {
3320
+ // A cooldown violation already carries a user-shaped headline plus
3321
+ @@ -59,7 +34,7 @@ async function handleErrors(isVerbose, fn) {
3322
+ const lines = (err.message ? err.message : err.toString()).split('\n');
3323
+ const bodyLines = lines.slice(1);
3324
+ if (isVerbose) {
3325
+ - bodyLines.push(...formatErrorStackAndCause(err, isVerbose));
3326
+ + bodyLines.push((0, error_types_1.formatErrorStackAndCause)(err));
3327
+ }
3328
+ else if (err.stack) {
3329
+ bodyLines.push('Pass --verbose to see the stacktrace.');
3330
+ @@ -76,16 +51,3 @@ async function handleErrors(isVerbose, fn) {
3331
+ return 1;
3332
+ }
3333
+ }
3334
+ -function formatErrorStackAndCause(error, verbose) {
3335
+ - return [
3336
+ - verbose ? error.stack || error.message : error.message,
3337
+ - ...(error.cause && typeof error.cause === 'object'
3338
+ - ? [
3339
+ - 'Caused by:',
3340
+ - verbose && 'stack' in error.cause
3341
+ - ? error.cause.stack.toString()
3342
+ - : error.cause.toString(),
3343
+ - ]
3344
+ - : []),
3345
+ - ];
3346
+ -}
3069
3347
  diff --git a/dist/src/utils/installation-directory.d.ts b/dist/src/utils/installation-directory.d.ts
3070
3348
  index dc1784edc9f48944589213847e653720b25990fc..f830bb52acb7f4652e45ea4afb7a24adc4adf7a8 100644
3071
3349
  --- a/dist/src/utils/installation-directory.d.ts