@smoothbricks/nx-plugin 0.5.2 → 0.5.4
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 +40 -9
- package/dist/cargo-source-hash.d.ts +2 -2
- package/dist/cargo-source-hash.d.ts.map +1 -1
- package/dist/cargo-source-hash.js +106 -46
- package/dist/executors/bounded-exec/cpu-tokens.d.ts +13 -0
- package/dist/executors/bounded-exec/cpu-tokens.d.ts.map +1 -1
- package/dist/executors/bounded-exec/cpu-tokens.js +9 -9
- package/dist/executors/bounded-exec/executor.d.ts.map +1 -1
- package/dist/executors/bounded-exec/executor.js +20 -6
- package/dist/executors/bounded-exec/progress.d.ts +8 -3
- package/dist/executors/bounded-exec/progress.d.ts.map +1 -1
- package/dist/executors/bounded-exec/progress.js +100 -10
- package/dist/executors/bounded-exec/verdict.d.ts +5 -4
- package/dist/executors/bounded-exec/verdict.d.ts.map +1 -1
- package/dist/executors/bounded-exec/verdict.js +1 -0
- package/dist/testing.js +1 -1
- package/managed/raw/patches/nx@23.2.1.patch +208 -45
- package/package.json +2 -2
- package/src/cargo-source-hash.test.ts +143 -2
- package/src/cargo-source-hash.ts +108 -44
- package/src/executors/bounded-exec/cpu-tokens.ts +15 -9
- package/src/executors/bounded-exec/executor.test.ts +26 -23
- package/src/executors/bounded-exec/executor.ts +19 -4
- package/src/executors/bounded-exec/go-progress-host.test.ts +171 -0
- package/src/executors/bounded-exec/progress.test.ts +73 -0
- package/src/executors/bounded-exec/progress.ts +95 -12
- package/src/executors/bounded-exec/verdict.ts +5 -4
- package/src/nx-daemon-start-never.test.ts +155 -0
- package/src/nx-task-output-lease.test.ts +136 -0
- package/src/testing.ts +1 -1
- package/test-timings.json +92 -91
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import typia from 'typia';
|
|
2
|
+
import { invocationSpan, withInvocationFlag } from './cpu-tokens.js';
|
|
3
|
+
import { BUN_TEST, GO_TEST, NEXTEST_RUN } from './verdict.js';
|
|
2
4
|
const ANSI = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*[A-Za-z]`, 'g');
|
|
3
5
|
/** Lines naming a test that finished; group 1 is its name. */
|
|
4
6
|
const FINISHED = [
|
|
@@ -12,14 +14,90 @@ const RUNNING = [
|
|
|
12
14
|
/^test (\S+) has been running for over \d+ seconds$/,
|
|
13
15
|
];
|
|
14
16
|
const DOTS = /^\.+$/;
|
|
15
|
-
|
|
17
|
+
const isGoTestEvent = (() => {
|
|
18
|
+
const _ip0 = input => "string" === typeof input["Package"];
|
|
19
|
+
const _ip1 = input => undefined === input["Test"] || "string" === typeof input["Test"];
|
|
20
|
+
const _io0 = input => "start" === input.Action && _ip0(input);
|
|
21
|
+
const _io1 = input => ("cont" === input.Action || "pause" === input.Action || "run" === input.Action) && _ip0(input) && "string" === typeof input.Test;
|
|
22
|
+
const _io2 = input => ("bench" === input.Action || "fail" === input.Action || "pass" === input.Action || "skip" === input.Action) && _ip0(input) && _ip1(input);
|
|
23
|
+
const _io3 = input => "output" === input.Action && _ip0(input) && "string" === typeof input.Output && _ip1(input);
|
|
24
|
+
const _iu0 = input => (() => {
|
|
25
|
+
if ("start" === input.Action)
|
|
26
|
+
return _io0(input);
|
|
27
|
+
else if ("bench" === input.Action || "fail" === input.Action || "pass" === input.Action || "skip" === input.Action)
|
|
28
|
+
return _io2(input);
|
|
29
|
+
else if ("cont" === input.Action || "pause" === input.Action || "run" === input.Action)
|
|
30
|
+
return _io1(input);
|
|
31
|
+
else if ("output" === input.Action)
|
|
32
|
+
return _io3(input);
|
|
33
|
+
else
|
|
34
|
+
return false;
|
|
35
|
+
})();
|
|
36
|
+
return input => "object" === typeof input && null !== input && _iu0(input);
|
|
37
|
+
})();
|
|
38
|
+
function goTestEvent(text) {
|
|
39
|
+
if (!text.startsWith('{'))
|
|
40
|
+
return null;
|
|
41
|
+
try {
|
|
42
|
+
const event = JSON.parse(text);
|
|
43
|
+
return isGoTestEvent(event) ? event : null;
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error instanceof SyntaxError)
|
|
47
|
+
return null;
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** Defer only a direct Go command/chain; an unknown shell wrapper or another runner keeps its existing bound. */
|
|
52
|
+
function onlyGoTests(command) {
|
|
53
|
+
let rest = command.trim();
|
|
54
|
+
while (rest.search(GO_TEST) === 0) {
|
|
55
|
+
rest = rest.slice(invocationSpan(rest, GO_TEST).argsEnd).trimStart();
|
|
56
|
+
if (rest === '')
|
|
57
|
+
return true;
|
|
58
|
+
const separator = /^(?:&&|\|\||;)\s*/.exec(rest);
|
|
59
|
+
if (separator === null)
|
|
60
|
+
return false;
|
|
61
|
+
rest = rest.slice(separator[0].length);
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
export function createRunProgress(command = '') {
|
|
66
|
+
const goLifecycle = onlyGoTests(command);
|
|
16
67
|
const streams = {
|
|
17
68
|
stdout: { partial: '', countedDots: 0 },
|
|
18
69
|
stderr: { partial: '', countedDots: 0 },
|
|
19
70
|
};
|
|
20
71
|
const running = new Set();
|
|
72
|
+
const packages = new Map();
|
|
21
73
|
// One complete line, ANSI stripped, that is not a line of dots: true when it names a finished test.
|
|
22
74
|
const finishedLine = (text) => {
|
|
75
|
+
const event = goTestEvent(text);
|
|
76
|
+
if (event !== null) {
|
|
77
|
+
switch (event.Action) {
|
|
78
|
+
case 'start':
|
|
79
|
+
packages.set(event.Package, new Set());
|
|
80
|
+
return false;
|
|
81
|
+
case 'run':
|
|
82
|
+
packages.get(event.Package)?.add(event.Test);
|
|
83
|
+
return false;
|
|
84
|
+
case 'pass':
|
|
85
|
+
case 'fail':
|
|
86
|
+
case 'skip':
|
|
87
|
+
case 'bench':
|
|
88
|
+
if (event.Test === undefined)
|
|
89
|
+
packages.delete(event.Package);
|
|
90
|
+
else
|
|
91
|
+
packages.get(event.Package)?.delete(event.Test);
|
|
92
|
+
return true;
|
|
93
|
+
case 'pause':
|
|
94
|
+
case 'cont':
|
|
95
|
+
case 'output':
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (goLifecycle)
|
|
100
|
+
return false;
|
|
23
101
|
for (const pattern of FINISHED) {
|
|
24
102
|
const name = pattern.exec(text)?.[1];
|
|
25
103
|
if (name !== undefined) {
|
|
@@ -47,7 +125,9 @@ export function createRunProgress() {
|
|
|
47
125
|
for (const raw of lines) {
|
|
48
126
|
const text = raw.replace(ANSI, '').trimEnd();
|
|
49
127
|
if (DOTS.test(text)) {
|
|
50
|
-
|
|
128
|
+
if (!goLifecycle && DOTS.test(text)) {
|
|
129
|
+
progressed ||= text.length > counted;
|
|
130
|
+
}
|
|
51
131
|
}
|
|
52
132
|
else if (finishedLine(text)) {
|
|
53
133
|
progressed = true;
|
|
@@ -55,13 +135,17 @@ export function createRunProgress() {
|
|
|
55
135
|
counted = 0;
|
|
56
136
|
}
|
|
57
137
|
const tail = rest.replace(ANSI, '');
|
|
58
|
-
const dots = DOTS.test(tail) ? tail.length : 0;
|
|
138
|
+
const dots = !goLifecycle && DOTS.test(tail) ? tail.length : 0;
|
|
59
139
|
progressed ||= dots > counted;
|
|
60
140
|
state.partial = rest;
|
|
61
141
|
state.countedDots = dots;
|
|
62
142
|
return progressed;
|
|
63
143
|
},
|
|
64
|
-
inFlight: () => [
|
|
144
|
+
inFlight: () => [
|
|
145
|
+
...running,
|
|
146
|
+
...[...packages].flatMap(([name, tests]) => tests.size === 0 ? [name] : [...tests].map((test) => `${name} ${test}`)),
|
|
147
|
+
],
|
|
148
|
+
isTesting: () => !goLifecycle || packages.size > 0,
|
|
65
149
|
};
|
|
66
150
|
}
|
|
67
151
|
/**
|
|
@@ -70,10 +154,16 @@ export function createRunProgress() {
|
|
|
70
154
|
* unchanged.
|
|
71
155
|
*/
|
|
72
156
|
export function withProgressReport(command) {
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
157
|
+
let reported = command;
|
|
158
|
+
for (const match of [...command.matchAll(new RegExp(GO_TEST, 'g'))].reverse()) {
|
|
159
|
+
reported =
|
|
160
|
+
reported.slice(0, match.index) +
|
|
161
|
+
withInvocationFlag(reported.slice(match.index), GO_TEST, /(?<![\w-])-json(?:=(?:true|false))?(?=\s|$)/g, '-json', true);
|
|
162
|
+
}
|
|
163
|
+
const bun = reported.match(BUN_TEST)?.length ?? 0;
|
|
164
|
+
const nextest = reported.match(NEXTEST_RUN)?.length ?? 0;
|
|
165
|
+
if (bun !== 1 || nextest !== 0 || /(?:^|\s)(?:--dots|--reporter[=\s]dots)(?=\s|$)/.test(reported)) {
|
|
166
|
+
return reported;
|
|
77
167
|
}
|
|
78
|
-
return
|
|
168
|
+
return reported.replace(BUN_TEST, (_match, runtime) => `${runtime} test --dots`);
|
|
79
169
|
}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* - `bound`: the run hit a wall-clock bound and nothing else failed. Either the command
|
|
6
6
|
* outlived `timeoutMs` (`total`), or every failing test in the runner's report failed on
|
|
7
7
|
* its runner's per-test timeout (`test`). A loaded host produces exactly these.
|
|
8
|
-
* - `wedged`: `idleTimeoutMs` fired: no test finished for that long
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* - `wedged`: `idleTimeoutMs` fired: no test finished for that long during a chargeable test interval. This proves
|
|
9
|
+
* the suite's completion bound was exceeded, not that every process stopped: an expensive active fixture can
|
|
10
|
+
* exceed it too. The verdict names tests reported running but never finished and tests the report says were
|
|
11
|
+
* aborted; diagnostics distinguish a stalled wait from a progressing but oversized lifecycle.
|
|
12
12
|
* - `no-space`: the run failed and its output said a write found no space (ENOSPC). Whatever its tests then reported,
|
|
13
13
|
* they failed on the disk, not on their own: the verdict names the line that said so and, when the task held one,
|
|
14
14
|
* its RAM temp volume as it stood when that line arrived.
|
|
@@ -147,6 +147,7 @@ export declare const JUNIT_FILE = "report.xml";
|
|
|
147
147
|
*/
|
|
148
148
|
export declare const BUN_TEST: RegExp;
|
|
149
149
|
export declare const NEXTEST_RUN: RegExp;
|
|
150
|
+
export declare const GO_TEST: RegExp;
|
|
150
151
|
/**
|
|
151
152
|
* `command` with its test runner asked to write a JUnit report into `directory`, the report
|
|
152
153
|
* `judgeRun` reads. Both runners are recognised by their invocation, so every target that runs
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../../src/executors/bounded-exec/verdict.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAA;CAAE,GAC9B;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC5G;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GACxF;IACE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC,GACD,CAAC;IAAE,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,eAAe,CAAC,GAClH;IAAE,QAAQ,CAAC,OAAO,EAAE,QA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157,7 @@ const NEXTEST_REPORT_CONFIG_FILE = 'nextest-report.toml';
|
|
|
157
157
|
*/
|
|
158
158
|
export const BUN_TEST = /(?<=^|[\s;&|()])((?:[^\s;&|()<>'"`\\=]*\/)?bun)\s+test(?=\s|$)/g;
|
|
159
159
|
export const NEXTEST_RUN = /(?<=^|[\s;&|()-])nextest\s+run(?=\s|$)/g;
|
|
160
|
+
export const GO_TEST = /(?<=^|[\s;&|()])go\s+test(?=\s|$)/;
|
|
160
161
|
/**
|
|
161
162
|
* `command` with its test runner asked to write a JUnit report into `directory`, the report
|
|
162
163
|
* `judgeRun` reads. Both runners are recognised by their invocation, so every target that runs
|
package/dist/testing.js
CHANGED
|
@@ -145,7 +145,7 @@ export async function pidsWorkingIn(root) {
|
|
|
145
145
|
for (const pid of (await readdir('/proc')).filter((name) => /^\d+$/.test(name))) {
|
|
146
146
|
const cwd = await readlink(`/proc/${pid}/cwd`).catch((error) => {
|
|
147
147
|
// Another user's process, or one that exited since the listing.
|
|
148
|
-
if (errorCode(error) === 'EACCES' || errorCode(error) === 'ENOENT') {
|
|
148
|
+
if (errorCode(error) === 'EACCES' || errorCode(error) === 'ENOENT' || errorCode(error) === 'ESRCH') {
|
|
149
149
|
return null;
|
|
150
150
|
}
|
|
151
151
|
throw error;
|
|
@@ -67,6 +67,32 @@ index 5a59f762f2002f61f84d0966c8fb48d48b3bdce2..f190d2b93cc7c1d0f59dcb1e76ef7d3e
|
|
|
67
67
|
function handleNoWorkspace(globalNxVersion) {
|
|
68
68
|
output_1.output.log({
|
|
69
69
|
title: `The current directory isn't part of an Nx workspace.`,
|
|
70
|
+
diff --git a/dist/src/command-line/daemon/daemon.js b/dist/src/command-line/daemon/daemon.js
|
|
71
|
+
index 237830c6863aa8c5bdab8c4794c6fc9f1e4a48b5..857a97118d646f25f61696b2db672de56f558327 100644
|
|
72
|
+
--- a/dist/src/command-line/daemon/daemon.js
|
|
73
|
+
+++ b/dist/src/command-line/daemon/daemon.js
|
|
74
|
+
@@ -7,6 +7,21 @@ const handle_import_1 = require("../../utils/handle-import");
|
|
75
|
+
const output_1 = require("../../utils/output");
|
|
76
|
+
async function daemonHandler(args) {
|
|
77
|
+
const { daemonClient } = await (0, handle_import_1.handleImport)('../../daemon/client/client.js', __dirname);
|
|
78
|
+
+ if (args.start && process.env.NX_DAEMON_START === 'never') {
|
|
79
|
+
+ // An explicit start is a start: under the rule every cowshed job runs
|
|
80
|
+
+ // with, it is refused as policy, never quietly honoured, or one command
|
|
81
|
+
+ // would recreate the daemon that outlives its job.
|
|
82
|
+
+ output_1.output.error({
|
|
83
|
+
+ title: 'Nx daemon not started: NX_DAEMON_START=never forbids this client starting a daemon',
|
|
84
|
+
+ bodyLines: [
|
|
85
|
+
+ 'Every cowshed job runs under it, so no daemon outlives the job that started it.',
|
|
86
|
+
+ "The checkout's daemon is its keeper's to start. A test that must start its own daemon runs that one nx",
|
|
87
|
+
+ 'without NX_DAEMON_START, through its named fixture escape (FIXTURE_STARTS_ITS_OWN_DAEMON).',
|
|
88
|
+
+ ],
|
|
89
|
+
+ });
|
|
90
|
+
+ // The handler's number is the command's exit code (handleErrors).
|
|
91
|
+
+ return 1;
|
|
92
|
+
+ }
|
|
93
|
+
if (args.start) {
|
|
94
|
+
const pid = await daemonClient.startInBackground();
|
|
95
|
+
output_1.output.log({
|
|
70
96
|
diff --git a/dist/src/command-line/release/version/version-actions.js b/dist/src/command-line/release/version/version-actions.js
|
|
71
97
|
index 006c077033a6e92a8bdcc6c732110736fb465b5a..2ac4a0252c813cec5492b7ac83e2d5160b97bc32 100644
|
|
72
98
|
--- a/dist/src/command-line/release/version/version-actions.js
|
|
@@ -343,7 +369,7 @@ index 9bd7b61bf9ad94c72a198dfe6f15fbcb68dfaac3..c552b4b252c2d0496312ddb6ff481699
|
|
|
343
369
|
flushSyncGeneratorChangesToDisk(generators: string[]): Promise<FlushSyncGeneratorChangesResult>;
|
|
344
370
|
getRegisteredSyncGenerators(): Promise<{
|
|
345
371
|
diff --git a/dist/src/daemon/client/client.js b/dist/src/daemon/client/client.js
|
|
346
|
-
index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..
|
|
372
|
+
index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..a1aeb1ac56800af773219df4f55ee95e324f1a26 100644
|
|
347
373
|
--- a/dist/src/daemon/client/client.js
|
|
348
374
|
+++ b/dist/src/daemon/client/client.js
|
|
349
375
|
@@ -40,7 +40,6 @@ const nx_console_1 = require("../message-types/nx-console");
|
|
@@ -354,7 +380,23 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..31fcb14fbf3811f0e1c545791026e5a6
|
|
|
354
380
|
const update_workspace_context_1 = require("../message-types/update-workspace-context");
|
|
355
381
|
const tmp_dir_1 = require("../tmp-dir");
|
|
356
382
|
const sandbox_socket_hint_1 = require("../sandbox-socket-hint");
|
|
357
|
-
@@ -
|
|
383
|
+
@@ -135,6 +134,15 @@ class DaemonClient {
|
|
384
|
+
});
|
|
385
|
+
this._enabled = false;
|
|
386
|
+
}
|
|
387
|
+
+ else if (process.env.NX_DAEMON_START === 'never' && !recordedDaemonRuns()) {
|
|
388
|
+
+ // A client that may never start a daemon (every cowshed job's) and
|
|
389
|
+
+ // finds none running computes this command in its own process. A
|
|
390
|
+
+ // daemon it started would serve every client of the checkout through
|
|
391
|
+
+ // the shared record while belonging to this client's job, and end
|
|
392
|
+
+ // with it.
|
|
393
|
+
+ logger_1.clientLogger.log(`[Client] NX_DAEMON_START=never and the recorded daemon is not running: running without the daemon`);
|
|
394
|
+
+ this._enabled = false;
|
|
395
|
+
+ }
|
|
396
|
+
else {
|
|
397
|
+
this._enabled = true;
|
|
398
|
+
}
|
|
399
|
+
@@ -668,27 +676,6 @@ class DaemonClient {
|
|
358
400
|
};
|
|
359
401
|
return this.sendToDaemonViaQueue(message);
|
|
360
402
|
}
|
|
@@ -382,7 +424,33 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..31fcb14fbf3811f0e1c545791026e5a6
|
|
|
382
424
|
getSyncGeneratorChanges(generators) {
|
|
383
425
|
const message = {
|
|
384
426
|
type: get_sync_generator_changes_1.GET_SYNC_GENERATOR_CHANGES,
|
|
385
|
-
@@ -
|
|
427
|
+
@@ -813,8 +800,23 @@ class DaemonClient {
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
if (!probe.available) {
|
|
431
|
+
- // Carried as a value so no other caller's probe can substitute for it.
|
|
432
|
+
- daemonPid = await this.startInBackground(probe.refusal);
|
|
433
|
+
+ if (process.env.NX_DAEMON_START === 'never') {
|
|
434
|
+
+ // The daemon enabled() found running has stopped since. Its
|
|
435
|
+
+ // successor is its starter's (cowshed's keeper) to start, never
|
|
436
|
+
+ // this client's. The stop belongs to that owner, not to the
|
|
437
|
+
+ // workspace, so the daemon is off for this process alone: no
|
|
438
|
+
+ // marker that an ordinary terminal would inherit.
|
|
439
|
+
+ const reason = 'The Nx daemon this client was using stopped, and NX_DAEMON_START=never: this client never starts a daemon.';
|
|
440
|
+
+ (0, tmp_dir_1.disableDaemonForThisProcess)(reason);
|
|
441
|
+
+ this._daemonStatus = DaemonStatus.DISCONNECTED;
|
|
442
|
+
+ const error = new Error(reason);
|
|
443
|
+
+ error.daemonStartForbidden = true;
|
|
444
|
+
+ throw error;
|
|
445
|
+
+ }
|
|
446
|
+
+ else {
|
|
447
|
+
+ // Carried as a value so no other caller's probe can substitute for it.
|
|
448
|
+
+ daemonPid = await this.startInBackground(probe.refusal);
|
|
449
|
+
+ }
|
|
450
|
+
}
|
|
451
|
+
this.setUpConnection();
|
|
452
|
+
this._daemonStatus = DaemonStatus.CONNECTED;
|
|
453
|
+
@@ -831,13 +833,24 @@ class DaemonClient {
|
|
386
454
|
}
|
|
387
455
|
}
|
|
388
456
|
async sendToDaemonViaQueue(messageToDaemon, parser) {
|
|
@@ -414,7 +482,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..31fcb14fbf3811f0e1c545791026e5a6
|
|
|
414
482
|
}
|
|
415
483
|
setUpConnection() {
|
|
416
484
|
const socketPath = this.getSocketPath();
|
|
417
|
-
@@ -846,7 +
|
|
485
|
+
@@ -846,7 +859,13 @@ class DaemonClient {
|
|
418
486
|
// sendMessageToDaemon method uses a keep-alive setTimeout to
|
|
419
487
|
// explicitly hold the event loop open while awaiting a response.
|
|
420
488
|
socket.unref();
|
|
@@ -429,7 +497,7 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..31fcb14fbf3811f0e1c545791026e5a6
|
|
|
429
497
|
// it's ok for the daemon to terminate if the client doesn't wait on
|
|
430
498
|
// any messages from the daemon
|
|
431
499
|
if (this.queue.isEmpty()) {
|
|
432
|
-
@@ -1132,8 +
|
|
500
|
+
@@ -1132,8 +1151,11 @@ class DaemonClient {
|
|
433
501
|
*/
|
|
434
502
|
const { available, refusal: polled } = await this.waitForServerToBeAvailable({ ignoreVersionMismatch: true });
|
|
435
503
|
if (available) {
|
|
@@ -443,6 +511,33 @@ index cebfd6d1f8ddb2c5b93dcb847904aa9ab0553de6..31fcb14fbf3811f0e1c545791026e5a6
|
|
|
443
511
|
}
|
|
444
512
|
else {
|
|
445
513
|
// A permission refusal from either source wins, then the poll's errno,
|
|
514
|
+
@@ -1200,6 +1222,26 @@ function isDocker() {
|
|
515
|
+
function nxJsonIsNotPresent() {
|
|
516
|
+
return !(0, nx_json_1.hasNxJson)(workspace_root_1.workspaceRoot);
|
|
517
|
+
}
|
|
518
|
+
+/**
|
|
519
|
+
+ * Whether the process the daemon record names still runs. Read only under
|
|
520
|
+
+ * NX_DAEMON_START=never, before any request, to choose between that daemon and
|
|
521
|
+
+ * none: a record whose daemon has gone is a reason to run without one, never to
|
|
522
|
+
+ * start one.
|
|
523
|
+
+ */
|
|
524
|
+
+function recordedDaemonRuns() {
|
|
525
|
+
+ const pid = (0, cache_1.getDaemonProcessIdSync)();
|
|
526
|
+
+ if (!Number.isInteger(pid) || pid < 1) {
|
|
527
|
+
+ return false;
|
|
528
|
+
+ }
|
|
529
|
+
+ try {
|
|
530
|
+
+ process.kill(pid, 0);
|
|
531
|
+
+ return true;
|
|
532
|
+
+ }
|
|
533
|
+
+ catch (err) {
|
|
534
|
+
+ // EPERM: a process this one may not signal holds the pid, so it runs.
|
|
535
|
+
+ return err.code === 'EPERM';
|
|
536
|
+
+ }
|
|
537
|
+
+}
|
|
538
|
+
/**
|
|
539
|
+
* The operating system refused the connection. Most often the socket belongs to
|
|
540
|
+
* another user, which is the guarantee the owner-only socket directory buys —
|
|
446
541
|
diff --git a/dist/src/daemon/message-types/daemon-message.d.ts b/dist/src/daemon/message-types/daemon-message.d.ts
|
|
447
542
|
index 9dd6123ad6d9adb20a07f7db56fc476be78cbcca..0b1ee217729d63a29806cf6c38d0fc5d4a2161a5 100644
|
|
448
543
|
--- a/dist/src/daemon/message-types/daemon-message.d.ts
|
|
@@ -2121,7 +2216,7 @@ index 3659fdd1955d56e60cc0158d19ac55d59916d78e..92e6700adfc52a380b3e9e37b655fbc9
|
|
|
2121
2216
|
/**
|
|
2122
2217
|
* Returns the current session count for a phase. Useful for testing.
|
|
2123
2218
|
diff --git a/dist/src/project-graph/project-graph.js b/dist/src/project-graph/project-graph.js
|
|
2124
|
-
index a23de7d0f27d7bc222ee09f4904f5d236510d01d..
|
|
2219
|
+
index a23de7d0f27d7bc222ee09f4904f5d236510d01d..0d8514be79f2ed03c7cc2410ea0d91f7c885d634 100644
|
|
2125
2220
|
--- a/dist/src/project-graph/project-graph.js
|
|
2126
2221
|
+++ b/dist/src/project-graph/project-graph.js
|
|
2127
2222
|
@@ -149,14 +149,7 @@ function handleProjectGraphError(opts, e) {
|
|
@@ -2140,6 +2235,21 @@ index a23de7d0f27d7bc222ee09f4904f5d236510d01d..247ed0fe9f7a1a1a3d8d91d0d772763e
|
|
|
2140
2235
|
}
|
|
2141
2236
|
else if (typeof e.message === 'string') {
|
|
2142
2237
|
const lines = e.message.split('\n');
|
|
2238
|
+
@@ -356,6 +349,14 @@ async function createProjectGraphAndSourceMapsAsync(opts = {
|
|
2239
|
+
(0, tmp_dir_1.markDaemonAsDisabled)(e.message);
|
|
2240
|
+
return buildProjectGraphAndSourceMapsWithoutDaemon();
|
|
2241
|
+
}
|
|
2242
|
+
+ if (e.daemonStartForbidden) {
|
|
2243
|
+
+ // The daemon stopped under a client that may not start one
|
|
2244
|
+
+ // (NX_DAEMON_START=never). The client already turned the daemon off
|
|
2245
|
+
+ // for this process alone; the command continues without it.
|
|
2246
|
+
+ output_1.output.note({ title: `${e.message} Continuing without the daemon.` });
|
|
2247
|
+
+ client_1.daemonClient.reset();
|
|
2248
|
+
+ return buildProjectGraphAndSourceMapsWithoutDaemon();
|
|
2249
|
+
+ }
|
|
2250
|
+
if (e.daemonPermissionError) {
|
|
2251
|
+
// Deliberately not disabled: unlike the inotify limit above, a socket
|
|
2252
|
+
// owned by someone else stops being there when it is removed or the
|
|
2143
2253
|
diff --git a/dist/src/tasks-runner/cache.d.ts b/dist/src/tasks-runner/cache.d.ts
|
|
2144
2254
|
index 34aa44f81f1df63c5d33e58d8b55d15fcf1d7619..edf41406f465726828fa447bd10d71a49a2ede8a 100644
|
|
2145
2255
|
--- a/dist/src/tasks-runner/cache.d.ts
|
|
@@ -3262,10 +3372,10 @@ index 0000000000000000000000000000000000000000..ab141ad0de874122b363f2fd1894dcbd
|
|
|
3262
3372
|
+}
|
|
3263
3373
|
diff --git a/dist/src/tasks-runner/task-output-lease.js b/dist/src/tasks-runner/task-output-lease.js
|
|
3264
3374
|
new file mode 100644
|
|
3265
|
-
index 0000000000000000000000000000000000000000..
|
|
3375
|
+
index 0000000000000000000000000000000000000000..df3e705647a8a38b28125df16ef0c73472b20df3
|
|
3266
3376
|
--- /dev/null
|
|
3267
3377
|
+++ b/dist/src/tasks-runner/task-output-lease.js
|
|
3268
|
-
@@ -0,0 +1,
|
|
3378
|
+
@@ -0,0 +1,233 @@
|
|
3269
3379
|
+"use strict";
|
|
3270
3380
|
+const { channel } = require("node:diagnostics_channel");
|
|
3271
3381
|
+const { writeFileSync } = require("node:fs");
|
|
@@ -3281,12 +3391,20 @@ index 0000000000000000000000000000000000000000..9f8639b22d29c8a4aca18a0efaec7a26
|
|
|
3281
3391
|
+// lock files are never unlinked or replaced.
|
|
3282
3392
|
+if (process.argv[2] === "--nx-task-output-lease-worker") {
|
|
3283
3393
|
+ let held = [];
|
|
3394
|
+
+ // One FileLock, so one descriptor, per lock file for the helper's life:
|
|
3395
|
+
+ // FileLock has no close, and a fresh one per acquire kept every descriptor
|
|
3396
|
+
+ // until garbage collection.
|
|
3397
|
+
+ const locks = new Map();
|
|
3284
3398
|
+ process.on("disconnect", () => process.exit(0));
|
|
3285
3399
|
+ process.on("message", (message) => {
|
|
3286
3400
|
+ try {
|
|
3287
3401
|
+ if (message.type === "acquire") {
|
|
3288
3402
|
+ for (const path of message.paths) {
|
|
3289
|
-
+
|
|
3403
|
+
+ let lock = locks.get(path);
|
|
3404
|
+
+ if (!lock) {
|
|
3405
|
+
+ lock = new FileLock(path);
|
|
3406
|
+
+ locks.set(path, lock);
|
|
3407
|
+
+ }
|
|
3290
3408
|
+ lock.lock();
|
|
3291
3409
|
+ held.push({ lock, path });
|
|
3292
3410
|
+ writeFileSync(path, JSON.stringify({ pid: process.pid, clientPid: process.ppid, purpose: message.purpose, targets: message.targets }));
|
|
@@ -3312,12 +3430,21 @@ index 0000000000000000000000000000000000000000..9f8639b22d29c8a4aca18a0efaec7a26
|
|
|
3312
3430
|
+ });
|
|
3313
3431
|
+}
|
|
3314
3432
|
+else {
|
|
3433
|
+
+ // The pool's slots. A slot is held by a live helper in `workers`; an acquire
|
|
3434
|
+
+ // that finds none free waits in `waiters` for one of exactly two events:
|
|
3435
|
+
+ // a release hands it the released helper, or a helper leaves the pool
|
|
3436
|
+
+ // (exit, failed spawn, failed send, or an error reply, after which it is
|
|
3437
|
+
+ // killed) and `retire` hands it that helper's slot to fork a successor.
|
|
3438
|
+
+ // Every way a helper can stop serving goes through `retire`, so no waiter
|
|
3439
|
+
+ // waits for a slot nothing will free.
|
|
3315
3440
|
+ class TaskOutputLeases {
|
|
3316
3441
|
+ constructor(parallelism, invocationTracker, purpose) {
|
|
3317
3442
|
+ this.purpose = purpose;
|
|
3318
3443
|
+ this.invocationTracker = invocationTracker;
|
|
3319
3444
|
+ this.parallelism = Math.max(1, parallelism);
|
|
3320
3445
|
+ this.workers = new Set();
|
|
3446
|
+
+ this.children = new Set();
|
|
3447
|
+
+ this.reserved = 0;
|
|
3321
3448
|
+ this.idle = [];
|
|
3322
3449
|
+ this.waiters = [];
|
|
3323
3450
|
+ this.stopping = false;
|
|
@@ -3347,43 +3474,17 @@ index 0000000000000000000000000000000000000000..9f8639b22d29c8a4aca18a0efaec7a26
|
|
|
3347
3474
|
+ const paths = targets.map((target) => join(workspaceDataDirectory, "task-output-leases", `${hashArray([this.purpose, target])}.lock`));
|
|
3348
3475
|
+ events.publish({ phase: "waiting", purpose: this.purpose, targets, paths, pid: process.pid });
|
|
3349
3476
|
+ let entry = this.idle.pop();
|
|
3350
|
-
+ if (!entry && this.workers.size >= this.parallelism) {
|
|
3477
|
+
+ if (!entry && this.workers.size + this.reserved >= this.parallelism) {
|
|
3478
|
+
+ // An entry from a release, or null: a retired helper's slot, reserved for this acquire.
|
|
3351
3479
|
+ entry = await new Promise((resolve, reject) => this.waiters.push({ resolve, reject }));
|
|
3480
|
+
+ if (!entry) this.reserved--;
|
|
3481
|
+
+ if (this.stopping) {
|
|
3482
|
+
+ if (entry) this.idle.push(entry);
|
|
3483
|
+
+ throw new Error(`Task output lease acquisition cancelled during runner cleanup: ${targets.join(", ")}`);
|
|
3484
|
+
+ }
|
|
3352
3485
|
+ }
|
|
3353
3486
|
+ if (!entry) {
|
|
3354
|
-
+
|
|
3355
|
-
+ execPath: process.execPath,
|
|
3356
|
-
+ execArgv: [],
|
|
3357
|
-
+ stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
3358
|
-
+ });
|
|
3359
|
-
+ entry = { worker, pending: null, failed: null, phase: "idle", exited: null };
|
|
3360
|
-
+ entry.exited = new Promise((resolve) => worker.once("exit", resolve));
|
|
3361
|
-
+ this.workers.add(entry);
|
|
3362
|
-
+ worker.on("message", (message) => {
|
|
3363
|
-
+ const pending = entry.pending;
|
|
3364
|
-
+ entry.pending = null;
|
|
3365
|
-
+ if (message.type === "error") {
|
|
3366
|
-
+ const error = new Error(`Task output lease for ${entry.targets.join(", ")} at ${entry.paths.join(", ")} failed: ${message.message}`);
|
|
3367
|
-
+ error.stack += `\nCaused by lease helper:\n${message.stack}`;
|
|
3368
|
-
+ entry.failed = error;
|
|
3369
|
-
+ pending?.reject(error);
|
|
3370
|
-
+ }
|
|
3371
|
-
+ else {
|
|
3372
|
-
+ pending?.resolve();
|
|
3373
|
-
+ }
|
|
3374
|
-
+ });
|
|
3375
|
-
+ worker.on("error", (cause) => {
|
|
3376
|
-
+ const error = new Error(`Task output lease helper failed for ${entry.targets.join(", ")} at ${entry.paths.join(", ")}`, { cause });
|
|
3377
|
-
+ entry.failed = error;
|
|
3378
|
-
+ entry.pending?.reject(error);
|
|
3379
|
-
+ entry.pending = null;
|
|
3380
|
-
+ });
|
|
3381
|
-
+ worker.on("exit", (code, signal) => {
|
|
3382
|
-
+ entry.failed ??= new Error(`Task output lease worker exited (code ${code}, signal ${signal ?? "none"}) for ${entry.targets.join(", ")} at ${entry.paths.join(", ")}`);
|
|
3383
|
-
+ entry.pending?.reject(entry.failed);
|
|
3384
|
-
+ entry.pending = null;
|
|
3385
|
-
+ this.workers.delete(entry);
|
|
3386
|
-
+ });
|
|
3487
|
+
+ entry = this.spawn();
|
|
3387
3488
|
+ }
|
|
3388
3489
|
+ entry.targets = targets;
|
|
3389
3490
|
+ entry.paths = paths;
|
|
@@ -3404,11 +3505,73 @@ index 0000000000000000000000000000000000000000..9f8639b22d29c8a4aca18a0efaec7a26
|
|
|
3404
3505
|
+ else this.idle.push(entry);
|
|
3405
3506
|
+ };
|
|
3406
3507
|
+ }
|
|
3508
|
+
+ spawn() {
|
|
3509
|
+
+ const worker = fork(__filename, ["--nx-task-output-lease-worker"], {
|
|
3510
|
+
+ execPath: process.execPath,
|
|
3511
|
+
+ execArgv: [],
|
|
3512
|
+
+ stdio: ["ignore", "inherit", "inherit", "ipc"],
|
|
3513
|
+
+ });
|
|
3514
|
+
+ const exited = Promise.withResolvers();
|
|
3515
|
+
+ const entry = { worker, pending: null, failed: null, retired: false, phase: "idle", exited: exited.promise, targets: [], paths: [] };
|
|
3516
|
+
+ const gone = () => {
|
|
3517
|
+
+ this.children.delete(entry);
|
|
3518
|
+
+ exited.resolve();
|
|
3519
|
+
+ };
|
|
3520
|
+
+ this.workers.add(entry);
|
|
3521
|
+
+ this.children.add(entry);
|
|
3522
|
+
+ worker.on("message", (message) => {
|
|
3523
|
+
+ const pending = entry.pending;
|
|
3524
|
+
+ entry.pending = null;
|
|
3525
|
+
+ if (message.type === "error") {
|
|
3526
|
+
+ // The helper unlocked what it held before replying; it no longer serves.
|
|
3527
|
+
+ const error = new Error(`Task output lease for ${entry.targets.join(", ")} at ${entry.paths.join(", ")} failed: ${message.message}`);
|
|
3528
|
+
+ error.stack += `\nCaused by lease helper:\n${message.stack}`;
|
|
3529
|
+
+ pending?.reject(error);
|
|
3530
|
+
+ this.retire(entry, error);
|
|
3531
|
+
+ }
|
|
3532
|
+
+ else {
|
|
3533
|
+
+ pending?.resolve();
|
|
3534
|
+
+ }
|
|
3535
|
+
+ });
|
|
3536
|
+
+ worker.on("error", (cause) => {
|
|
3537
|
+
+ this.retire(entry, new Error(`Task output lease helper failed for ${entry.targets.join(", ")} at ${entry.paths.join(", ")}`, { cause }));
|
|
3538
|
+
+ // A helper that never started emits no exit.
|
|
3539
|
+
+ if (worker.pid === undefined) gone();
|
|
3540
|
+
+ });
|
|
3541
|
+
+ worker.on("exit", (code, signal) => {
|
|
3542
|
+
+ this.retire(entry, new Error(`Task output lease worker exited (code ${code}, signal ${signal ?? "none"}) for ${entry.targets.join(", ")} at ${entry.paths.join(", ")}`));
|
|
3543
|
+
+ gone();
|
|
3544
|
+
+ });
|
|
3545
|
+
+ return entry;
|
|
3546
|
+
+ }
|
|
3547
|
+
+ // Takes a helper that no longer serves out of the pool, once: its
|
|
3548
|
+
+ // pending exchange fails with the reason, and its slot goes to the
|
|
3549
|
+
+ // oldest waiter, which forks a successor.
|
|
3550
|
+
+ retire(entry, error) {
|
|
3551
|
+
+ if (entry.retired) return;
|
|
3552
|
+
+ entry.retired = true;
|
|
3553
|
+
+ entry.failed ??= error;
|
|
3554
|
+
+ entry.pending?.reject(entry.failed);
|
|
3555
|
+
+ entry.pending = null;
|
|
3556
|
+
+ // A live helper that stopped serving holds no lease: its error reply unlocked them, or a failed send left
|
|
3557
|
+
+ // it unreachable. Killing it releases whatever the kernel still records.
|
|
3558
|
+
+ entry.worker.kill("SIGKILL");
|
|
3559
|
+
+ this.workers.delete(entry);
|
|
3560
|
+
+ const index = this.idle.indexOf(entry);
|
|
3561
|
+
+ if (index !== -1) this.idle.splice(index, 1);
|
|
3562
|
+
+ const waiter = this.waiters.shift();
|
|
3563
|
+
+ if (waiter) {
|
|
3564
|
+
+ this.reserved++;
|
|
3565
|
+
+ waiter.resolve(null);
|
|
3566
|
+
+ }
|
|
3567
|
+
+ }
|
|
3407
3568
|
+ exchange(entry, message) {
|
|
3408
3569
|
+ if (entry.failed) return Promise.reject(entry.failed);
|
|
3409
3570
|
+ return new Promise((resolve, reject) => {
|
|
3410
3571
|
+ entry.pending = { resolve, reject };
|
|
3411
|
-
+ entry.worker.send(message)
|
|
3572
|
+
+ entry.worker.send(message, (error) => {
|
|
3573
|
+
+ if (error) this.retire(entry, new Error(`Task output lease helper for ${entry.targets.join(", ")} at ${entry.paths.join(", ")} could not be sent ${message.type}`, { cause: error }));
|
|
3574
|
+
+ });
|
|
3412
3575
|
+ });
|
|
3413
3576
|
+ }
|
|
3414
3577
|
+ async withTasks(tasks, action) {
|
|
@@ -3437,7 +3600,7 @@ index 0000000000000000000000000000000000000000..9f8639b22d29c8a4aca18a0efaec7a26
|
|
|
3437
3600
|
+ async close() {
|
|
3438
3601
|
+ await this.cancelPending();
|
|
3439
3602
|
+ this.closed = true;
|
|
3440
|
-
+ await Promise.all([...this.
|
|
3603
|
+
+ await Promise.all([...this.children].map((entry) => {
|
|
3441
3604
|
+ entry.worker.kill("SIGKILL");
|
|
3442
3605
|
+ return entry.exited;
|
|
3443
3606
|
+ }));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smoothbricks/nx-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./loader.js",
|
|
@@ -263,7 +263,7 @@
|
|
|
263
263
|
}
|
|
264
264
|
],
|
|
265
265
|
"options": {
|
|
266
|
-
"command": "bun test --timeout=0 ./src/executors/bounded-exec/ram-temp-host.test.ts ./src/executors/bounded-exec/executor-host.test.ts",
|
|
266
|
+
"command": "bun test --timeout=0 ./src/executors/bounded-exec/ram-temp-host.test.ts ./src/executors/bounded-exec/executor-host.test.ts ./src/executors/bounded-exec/go-progress-host.test.ts",
|
|
267
267
|
"cwd": "{projectRoot}",
|
|
268
268
|
"env": {
|
|
269
269
|
"COWSHED_EXECUTABLE": "{workspaceRoot}/packages/cowshed/bin/cowshed"
|