@antelopejs/dms 0.25.0 → 0.25.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.25.2
4
+
5
+ [compare changes](https://github.com/AntelopeJS/dms/compare/v0.25.1...v0.25.2)
6
+
7
+ ### 🔥 Performance
8
+
9
+ - **dms:** Start the e2e kit's runs together ([#1306](https://github.com/AntelopeJS/dms/pull/1306))
10
+
11
+ ### 🩹 Fixes
12
+
13
+ - **dms:** Key a symlinked scope folder of the e2e build key entry by entry ([#1307](https://github.com/AntelopeJS/dms/pull/1307))
14
+
15
+ ### 🏡 Chore
16
+
17
+ - **deps:** Update @antelopejs/tooling-configs to 0.10.14 and sync ([#1305](https://github.com/AntelopeJS/dms/pull/1305))
18
+
19
+ ### ❤️ Contributors
20
+
21
+ - Antony Rizzitelli
22
+
23
+ ## v0.25.1
24
+
25
+ [compare changes](https://github.com/AntelopeJS/dms/compare/v0.25.0...v0.25.1)
26
+
27
+ ### 🩹 Fixes
28
+
29
+ - **e2e:** Retry a failed journey once in the merge queue, reported as flaky ([#1302](https://github.com/AntelopeJS/dms/pull/1302))
30
+ - **e2e:** Make the backend and dashboard waits refuse a port another process holds ([#1301](https://github.com/AntelopeJS/dms/pull/1301))
31
+ - **dms:** Lay out a run copy of a playground with no node_modules of its own ([#1303](https://github.com/AntelopeJS/dms/pull/1303))
32
+
33
+ ### ❤️ Contributors
34
+
35
+ - Antony Rizzitelli
36
+
3
37
  ## v0.25.0
4
38
 
5
39
  [compare changes](https://github.com/AntelopeJS/dms/compare/v0.24.3...v0.25.0)
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * The Playwright config of a suite: two workers, each against a run of its
3
3
  * own that the global setup starts (one worker when `DMS_E2E_RUN` names
4
- * the run to drive), no retries, a test timeout above the kit's own waits,
4
+ * the run to drive), one retry in a GitHub merge-queue run (`merge_group`),
5
+ * which reports a pass on retry as flaky, and none elsewhere, a test timeout
6
+ * above the kit's own waits,
5
7
  * and the CI reporters. It is plain
6
8
  * Playwright config, so `defineConfig(e2eConfig(), overrides)` adjusts it.
7
9
  * The suite's journeys come from `e2e/journeys.config.ts` and
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Asks the kernel for a free loopback port outside `exclude`.
2
+ * Asks the kernel for a free loopback port outside `exclude` that this
3
+ * process has not given before.
3
4
  *
4
5
  * @param {Iterable<number>} [exclude] Skipped ports
5
6
  * @returns {Promise<number>} The port
@@ -14,11 +15,11 @@ export function freePort(exclude?: Iterable<number>): Promise<number>;
14
15
  */
15
16
  export function isRestartablePort(port: number): port is RestartablePort;
16
17
  /**
17
- * A free loopback port outside the ephemeral range and `exclude` for a server
18
- * that must listen on the same port again after it restarts. No outgoing
19
- * connection takes such a port as its source port, so none can hold it in
20
- * TIME_WAIT and make that listen fail with `EADDRINUSE`, as a port from
21
- * {@link freePort} can be held.
18
+ * A free loopback port outside the ephemeral range and `exclude`, which this
19
+ * process has not given before, for a server that must listen on the same
20
+ * port again after it restarts. No outgoing connection takes such a port as
21
+ * its source port, so none can hold it in TIME_WAIT and make that listen
22
+ * fail with `EADDRINUSE`, as a port from {@link freePort} can be held.
22
23
  *
23
24
  * @param {Iterable<number>} [exclude] Skipped ports
24
25
  * @returns {Promise<RestartablePort>} The port
@@ -66,56 +67,6 @@ export function runToEnd(spec: {
66
67
  env: NodeJS.ProcessEnv;
67
68
  logs: string;
68
69
  }): Promise<void>;
69
- /**
70
- * The status of one GET, or `null` when nothing answered.
71
- *
72
- * @param {string} url The URL
73
- * @returns {Promise<number | null>} The HTTP status
74
- */
75
- export function probe(url: string): Promise<number | null>;
76
- /**
77
- * Polls `url` until it answers 200, the process exits or the timeout passes.
78
- *
79
- * @param {string} url The readiness URL
80
- * @param {{ pid: number, log: string }} record The process that must serve it
81
- * @param {number} timeoutMs How long to wait
82
- * @returns {Promise<void>} Resolves once ready
83
- * @throws When the process exits first or the timeout passes, naming its log
84
- */
85
- export function waitForOk(url: string, record: {
86
- pid: number;
87
- log: string;
88
- }, timeoutMs: number): Promise<void>;
89
- /**
90
- * Polls a loopback port until it accepts a connection, the process exits or
91
- * the timeout passes.
92
- *
93
- * @param {number} port The port
94
- * @param {{ name: string, pid: number, log: string }} record The process that must listen
95
- * @param {number} timeoutMs How long to wait
96
- * @returns {Promise<void>} Resolves once it listens
97
- * @throws When the process exits first or the timeout passes, naming its log
98
- */
99
- export function waitForPort(port: number, record: {
100
- name: string;
101
- pid: number;
102
- log: string;
103
- }, timeoutMs: number): Promise<void>;
104
- /**
105
- * Polls until the process itself listens on the port, so a port another
106
- * program took after it was picked is not mistaken for ours.
107
- *
108
- * @param {number} port The port
109
- * @param {{ name: string, pid: number, log: string }} record The process that must listen
110
- * @param {number} timeoutMs How long to wait
111
- * @returns {Promise<void>} Resolves once the process listens
112
- * @throws When it exits first (the port was taken) or the timeout passes
113
- */
114
- export function waitForOwnPort(port: number, record: {
115
- name: string;
116
- pid: number;
117
- log: string;
118
- }, timeoutMs: number): Promise<void>;
119
70
  /**
120
71
  * Every live descendant of `pids`, read from /proc. Empty where /proc is
121
72
  * missing. A child that left the process group is found here too.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A `node_modules` that is `modules` with `@antelopejs/dms-frontend` replaced
3
3
  * by the renderer checkout and no `.cache`, every other entry linked to the
4
- * original.
4
+ * original. Without `modules`, it holds only the renderer.
5
5
  *
6
6
  * @param {string} modules The playground's installed modules
7
7
  * @param {string} shadow The run's `node_modules`
@@ -17,6 +17,8 @@ export function linkRenderer(modules: string, shadow: string, renderer: string):
17
17
  * the playground's but `.cache`, where a backend writes its MCP credential
18
18
  * and its packed modules, so that folder belongs to the run too; and
19
19
  * `@antelopejs/dms-frontend` is the `renderer` checkout when there is one.
20
+ * A playground with no `node_modules` of its own gets none, unless it has a
21
+ * `renderer`, and resolves its modules from the linked levels above it.
20
22
  *
21
23
  * @param {string} playground The playground folder
22
24
  * @param {string} checkout The checkout root, or the module folder outside one
@@ -78,14 +78,6 @@ export function launchBackend(state: RunState, database: string, build?: {
78
78
  * @returns {import("./run-state.mjs").BackendRecord[]} The backends
79
79
  */
80
80
  export function liveBackends(state: RunState): import("./run-state.mjs").BackendRecord[];
81
- /**
82
- * Waits until a backend answers `/api/onboarding/informations` on its own port.
83
- *
84
- * @param {import("./run-state.mjs").ServerRecord} backend The backend
85
- * @returns {Promise<void>} Resolves once it answers 200
86
- * @throws When it exits first or the timeout passes, naming its log
87
- */
88
- export function waitForBackend(backend: import("./run-state.mjs").ServerRecord): Promise<void>;
89
81
  /**
90
82
  * Starts the run's backend on `state.database`, from the run's build or
91
83
  * `build`, and points the API at it once it answers.
@@ -24,28 +24,28 @@ export function targetOf(options: Pick<StartOptions, "playground" | "renderer" |
24
24
  renderer: string | undefined;
25
25
  }>;
26
26
  /**
27
- * Starts the stack of a run: with `prepare`, the journeys config's install
28
- * and build commands first, then the stack on its playground and renderer.
27
+ * Starts the stack of a run on its playground and renderer, the journeys
28
+ * config's commands already run.
29
29
  *
30
30
  * @param {StartOptions} options How to start it
31
+ * @param {import("./timing.mjs").TimingEntry[]} prepared The timings of the commands, which the run records
31
32
  * @param {string} cwd Where the run starts from, which finds the journeys config
32
33
  * @returns {Promise<import("./run-state.mjs").RunState>} The ready run
33
34
  */
34
- export function startStack(options: StartOptions, cwd: string): Promise<import("./run-state.mjs").RunState>;
35
+ export function startStack(options: StartOptions, prepared: import("./timing.mjs").TimingEntry[], cwd: string): Promise<import("./run-state.mjs").RunState>;
35
36
  /**
36
37
  * Starts `count` runs of the checkout's playground, each with its own
37
38
  * playground copy, ports, MongoDB, mail sink, backends and dashboard, for
38
- * the workers of one suite to drive one each. The first runs the journeys
39
- * config's prepare commands as `options` asks; the others start once it is
40
- * ready, together, without them, so their dashboards come from the build
41
- * cache the first one filled. `stop` stops them all, and from the moment
42
- * the first is ready a SIGINT or SIGTERM to this process stops every run
43
- * started so far, then ends the process by that signal.
39
+ * the workers of one suite to drive one each. The journeys config's prepare
40
+ * commands run first, once, as `options` asks; then every run starts at the
41
+ * same time. `stop` stops them all, and from the moment the runs start a
42
+ * SIGINT or SIGTERM to this process stops every run ready so far, then
43
+ * ends the process by that signal.
44
44
  *
45
45
  * @param {RunOptions} options How to start them
46
46
  * @param {number} count How many, at least 1
47
- * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, and what stops them
48
- * @throws When a run fails to start; every run it started is stopped first
47
+ * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, one per worker, and what stops them
48
+ * @throws When a run fails to start; every run that started is stopped first
49
49
  */
50
50
  export function startRuns(options: RunOptions, count: number): Promise<{
51
51
  runs: import("./run-state.mjs").RunState[];
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The status of one GET, or `null` when nothing answered.
3
+ *
4
+ * @param {string} url The URL
5
+ * @returns {Promise<number | null>} The HTTP status
6
+ */
7
+ export function probe(url: string): Promise<number | null>;
8
+ /**
9
+ * Polls `url` until it answers 200, the process exits or the timeout passes.
10
+ *
11
+ * @param {string} url The readiness URL
12
+ * @param {{ pid: number, log: string }} record The process that must serve it
13
+ * @param {number} timeoutMs How long to wait
14
+ * @returns {Promise<void>} Resolves once ready
15
+ * @throws When the process exits first or the timeout passes, naming its log
16
+ */
17
+ export function waitForOk(url: string, record: {
18
+ pid: number;
19
+ log: string;
20
+ }, timeoutMs: number): Promise<void>;
21
+ /**
22
+ * Polls a loopback port until it accepts a connection, the process exits or
23
+ * the timeout passes.
24
+ *
25
+ * @param {number} port The port
26
+ * @param {{ name: string, pid: number, log: string }} record The process that must listen
27
+ * @param {number} timeoutMs How long to wait
28
+ * @returns {Promise<void>} Resolves once it listens
29
+ * @throws When the process exits first or the timeout passes, naming its log
30
+ */
31
+ export function waitForPort(port: number, record: {
32
+ name: string;
33
+ pid: number;
34
+ log: string;
35
+ }, timeoutMs: number): Promise<void>;
36
+ /**
37
+ * Polls until the process or one it started listens on the port, so a port
38
+ * another program took after it was picked is not mistaken for ours.
39
+ *
40
+ * @param {number} port The port
41
+ * @param {{ name: string, pid: number, log: string }} record The process that must listen
42
+ * @param {number} timeoutMs How long to wait
43
+ * @returns {Promise<void>} Resolves once the process listens
44
+ * @throws When it exits first (the port was taken) or the timeout passes
45
+ */
46
+ export function waitForOwnPort(port: number, record: {
47
+ name: string;
48
+ pid: number;
49
+ log: string;
50
+ }, timeoutMs: number): Promise<void>;
51
+ /**
52
+ * Waits until a backend listens on its own port and answers
53
+ * `/api/onboarding/informations` there.
54
+ *
55
+ * @param {import("./run-state.mjs").ServerRecord} backend The backend
56
+ * @returns {Promise<void>} Resolves once it answers 200
57
+ * @throws When it exits first, another process holds its port or the timeout passes, naming its log
58
+ */
59
+ export function waitForBackend(backend: import("./run-state.mjs").ServerRecord): Promise<void>;
60
+ /**
61
+ * Waits until the run's dashboard listens on the run's web port and answers
62
+ * `/dms-preview` there.
63
+ *
64
+ * @param {Pick<import("./run-state.mjs").RunState, "webPort" | "webUrl">} state The run
65
+ * @param {import("./run-state.mjs").ProcessRecord} frontend The dashboard's process
66
+ * @returns {Promise<void>} Resolves once it answers 200
67
+ * @throws When it exits first, another process holds its port or the timeout passes, naming its log
68
+ */
69
+ export function waitForDashboard(state: Pick<import("./run-state.mjs").RunState, "webPort" | "webUrl">, frontend: import("./run-state.mjs").ProcessRecord): Promise<void>;
package/e2e/backend.mjs CHANGED
@@ -11,8 +11,8 @@ import {
11
11
  record,
12
12
  runBackendMode,
13
13
  startBackend,
14
- waitForBackend,
15
14
  } from "./stack.mjs";
15
+ import { waitForBackend } from "./waits.mjs";
16
16
  import { recordTiming, stopwatch, timed } from "./timing.mjs";
17
17
 
18
18
  /** @typedef {import("./run-state.mjs").RunState} RunState */
package/e2e/build-key.mjs CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  readFileSync,
7
7
  readlinkSync,
8
8
  realpathSync,
9
+ statSync,
9
10
  } from "node:fs";
10
11
  import { basename, dirname, isAbsolute, join, relative, sep } from "node:path";
11
12
  import { isRecord } from "./json.mjs";
@@ -168,12 +169,12 @@ function hashFolder(folder, names, walk = SOURCES) {
168
169
 
169
170
  /**
170
171
  * Keys an entry at the top of a `node_modules` above the workspace, or in a
171
- * scope folder there. A scope folder is keyed entry by entry. A link is keyed
172
- * by its target, and, when the target is not a package of pnpm's virtual
173
- * store (a `link:` or `workspace:` package), by the content hash of the
174
- * folder it resolves to, its installs left out, read once however many links
175
- * reach it. A package copied in is keyed by its files, its own
176
- * `node_modules` included.
172
+ * scope folder there. A scope folder, or a link to one, is keyed entry by
173
+ * entry. Any other link is keyed by its target, and, when the target is not
174
+ * a package of pnpm's virtual store (a `link:` or `workspace:` package), by
175
+ * the content hash of the folder it resolves to, its installs left out,
176
+ * read once however many links reach it. A package copied in is keyed by
177
+ * its files, its own `node_modules` included.
177
178
  *
178
179
  * @param {import("node:crypto").Hash} hash
179
180
  * @param {string} path The entry
@@ -181,7 +182,7 @@ function hashFolder(folder, names, walk = SOURCES) {
181
182
  */
182
183
  function hashInstalled(hash, path, outside) {
183
184
  const stat = lstatSync(path, { throwIfNoEntry: false });
184
- if (stat?.isDirectory() && basename(path).startsWith("@")) {
185
+ if (isScope(path)) {
185
186
  hash.update("scope\0");
186
187
  for (const name of readdirSync(path).sort()) {
187
188
  hash.update(`${name}\0`);
@@ -208,6 +209,19 @@ function hashInstalled(hash, path, outside) {
208
209
  hash.update(`linked ${digest}\0`);
209
210
  }
210
211
 
212
+ /**
213
+ * @param {string} path An entry of a `node_modules`
214
+ * @returns {boolean} Whether it is a scope folder, or a link to one
215
+ */
216
+ function isScope(path) {
217
+ if (!basename(path).startsWith("@")) return false;
218
+ try {
219
+ return statSync(path).isDirectory();
220
+ } catch {
221
+ return false;
222
+ }
223
+ }
224
+
211
225
  /**
212
226
  * @param {string} path A real path
213
227
  * @returns {boolean}
@@ -228,7 +242,7 @@ function packagesIn(modules) {
228
242
  .filter((name) => !name.startsWith("."))
229
243
  .flatMap((name) => {
230
244
  const path = join(modules, name);
231
- return name.startsWith("@") && lstatSync(path).isDirectory()
245
+ return isScope(path)
232
246
  ? readdirSync(path).map((scoped) => join(path, scoped))
233
247
  : [path];
234
248
  });
package/e2e/dashboard.mjs CHANGED
@@ -5,7 +5,7 @@ import { join } from "node:path";
5
5
  import { setTimeout as sleep } from "node:timers/promises";
6
6
  import { arrayOf, decode, isBoolean, isRecord, objectOf } from "./json.mjs";
7
7
  import { frontendPackage } from "./launch.mjs";
8
- import { probe, waitForOk } from "./processes.mjs";
8
+ import { probe, waitForOk } from "./waits.mjs";
9
9
 
10
10
  const MODULE_SET = "./dist/module-set.js";
11
11
  const MANIFEST_PATH = "/dms/frontend?renderer=vue&rendererVersion=3";
package/e2e/index.mjs CHANGED
@@ -22,7 +22,9 @@ const WORKERS = 2;
22
22
  /**
23
23
  * The Playwright config of a suite: two workers, each against a run of its
24
24
  * own that the global setup starts (one worker when `DMS_E2E_RUN` names
25
- * the run to drive), no retries, a test timeout above the kit's own waits,
25
+ * the run to drive), one retry in a GitHub merge-queue run (`merge_group`),
26
+ * which reports a pass on retry as flaky, and none elsewhere, a test timeout
27
+ * above the kit's own waits,
26
28
  * and the CI reporters. It is plain
27
29
  * Playwright config, so `defineConfig(e2eConfig(), overrides)` adjusts it.
28
30
  * The suite's journeys come from `e2e/journeys.config.ts` and
@@ -45,7 +47,7 @@ export function e2eConfig(options = {}) {
45
47
  outputDir: `test-results${suffix}`,
46
48
  fullyParallel: true,
47
49
  workers: process.env.DMS_E2E_RUN ? 1 : WORKERS,
48
- retries: 0,
50
+ retries: process.env.GITHUB_EVENT_NAME === "merge_group" ? 1 : 0,
49
51
  forbidOnly: CI,
50
52
  timeout: 15 * MINUTE,
51
53
  globalSetup: fileURLToPath(new URL("global-setup.mjs", import.meta.url)),
package/e2e/mongo.mjs CHANGED
@@ -14,12 +14,8 @@ import {
14
14
  objectOf,
15
15
  recordOf,
16
16
  } from "./json.mjs";
17
- import {
18
- restartablePort,
19
- startDetached,
20
- stopRecorded,
21
- waitForOwnPort,
22
- } from "./processes.mjs";
17
+ import { restartablePort, startDetached, stopRecorded } from "./processes.mjs";
18
+ import { waitForOwnPort } from "./waits.mjs";
23
19
 
24
20
  /** A file name Node runs as a script. */
25
21
  const JAVASCRIPT_FILE = /\.[cm]?js$/u;
package/e2e/processes.mjs CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  readFileSync,
9
9
  readlinkSync,
10
10
  } from "node:fs";
11
- import { createConnection, createServer } from "node:net";
11
+ import { createServer } from "node:net";
12
12
  import { platform } from "node:os";
13
13
  import { join } from "node:path";
14
14
  import { setTimeout as sleep } from "node:timers/promises";
@@ -16,7 +16,6 @@ import {
16
16
  assertOwnProc,
17
17
  assertSignalable,
18
18
  hasProc,
19
- isAlive,
20
19
  isSameProcess,
21
20
  isSignalable,
22
21
  startedAs,
@@ -24,11 +23,9 @@ import {
24
23
  statOf,
25
24
  } from "./identity.mjs";
26
25
 
27
- const POLL_MS = 500;
28
26
  const READY_POLL_MS = 100;
29
27
  const KILL_POLL_MS = 10;
30
28
  const STOP_GRACE_MS = 10_000;
31
- const PROBE_TIMEOUT_MS = 3_000;
32
29
  const LISTEN_STATE = "0A";
33
30
  const HEX = 16;
34
31
  const EPHEMERAL_RANGE_FILE = "/proc/sys/net/ipv4/ip_local_port_range";
@@ -44,8 +41,22 @@ function isTcpAddress(address) {
44
41
  return typeof address === "object" && address !== null;
45
42
  }
46
43
 
44
+ /** Every port {@link freePort} or {@link restartablePort} gave in this process, which neither gives again: runs that start at the same time each pick a port before any of them listens on it. */
45
+ const handedOut = new Set();
46
+
47
+ /**
48
+ * @template {number} P
49
+ * @param {P} port A port to give
50
+ * @returns {P} The port, never to be given again in this process
51
+ */
52
+ function handOut(port) {
53
+ handedOut.add(port);
54
+ return port;
55
+ }
56
+
47
57
  /**
48
- * Asks the kernel for a free loopback port outside `exclude`.
58
+ * Asks the kernel for a free loopback port outside `exclude` that this
59
+ * process has not given before.
49
60
  *
50
61
  * @param {Iterable<number>} [exclude] Skipped ports
51
62
  * @returns {Promise<number>} The port
@@ -54,7 +65,7 @@ export async function freePort(exclude = []) {
54
65
  const skip = new Set(exclude);
55
66
  for (let n = 0; n < RESTARTABLE_PORT_ATTEMPTS; n += 1) {
56
67
  const port = await kernelPort();
57
- if (!skip.has(port)) return port;
68
+ if (!skip.has(port) && !handedOut.has(port)) return handOut(port);
58
69
  }
59
70
  throw new Error("no free port");
60
71
  }
@@ -118,11 +129,11 @@ export function isRestartablePort(port) {
118
129
  }
119
130
 
120
131
  /**
121
- * A free loopback port outside the ephemeral range and `exclude` for a server
122
- * that must listen on the same port again after it restarts. No outgoing
123
- * connection takes such a port as its source port, so none can hold it in
124
- * TIME_WAIT and make that listen fail with `EADDRINUSE`, as a port from
125
- * {@link freePort} can be held.
132
+ * A free loopback port outside the ephemeral range and `exclude`, which this
133
+ * process has not given before, for a server that must listen on the same
134
+ * port again after it restarts. No outgoing connection takes such a port as
135
+ * its source port, so none can hold it in TIME_WAIT and make that listen
136
+ * fail with `EADDRINUSE`, as a port from {@link freePort} can be held.
126
137
  *
127
138
  * @param {Iterable<number>} [exclude] Skipped ports
128
139
  * @returns {Promise<RestartablePort>} The port
@@ -144,9 +155,10 @@ export async function restartablePort(exclude = []) {
144
155
  if (
145
156
  isRestartablePort(port) &&
146
157
  !excluded.has(port) &&
147
- (await canListen(port))
158
+ (await canListen(port)) &&
159
+ !handedOut.has(port)
148
160
  )
149
- return port;
161
+ return handOut(port);
150
162
  }
151
163
  throw new Error("no loopback port outside the ephemeral range is free");
152
164
  }
@@ -243,103 +255,6 @@ export function runToEnd(spec) {
243
255
  });
244
256
  }
245
257
 
246
- /**
247
- * The status of one GET, or `null` when nothing answered.
248
- *
249
- * @param {string} url The URL
250
- * @returns {Promise<number | null>} The HTTP status
251
- */
252
- export async function probe(url) {
253
- try {
254
- const response = await fetch(url, {
255
- signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
256
- });
257
- await response.body?.cancel();
258
- return response.status;
259
- } catch {
260
- return null;
261
- }
262
- }
263
-
264
- /**
265
- * Polls `url` until it answers 200, the process exits or the timeout passes.
266
- *
267
- * @param {string} url The readiness URL
268
- * @param {{ pid: number, log: string }} record The process that must serve it
269
- * @param {number} timeoutMs How long to wait
270
- * @returns {Promise<void>} Resolves once ready
271
- * @throws When the process exits first or the timeout passes, naming its log
272
- */
273
- export async function waitForOk(url, record, timeoutMs) {
274
- const deadline = Date.now() + timeoutMs;
275
- while (Date.now() < deadline) {
276
- if (!isAlive(record.pid)) {
277
- throw new Error(`${url}: the process exited first; see ${record.log}`);
278
- }
279
- if ((await probe(url)) === 200) return;
280
- await sleep(READY_POLL_MS);
281
- }
282
- throw new Error(
283
- `${url} did not answer 200 in ${timeoutMs} ms; see ${record.log}`,
284
- );
285
- }
286
-
287
- /** @param {number} port */
288
- function accepts(port) {
289
- return new Promise((resolve) => {
290
- const socket = createConnection({ host: "127.0.0.1", port });
291
- socket.once("connect", () => {
292
- socket.end();
293
- resolve(true);
294
- });
295
- socket.once("error", () => resolve(false));
296
- });
297
- }
298
-
299
- /**
300
- * Polls a loopback port until it accepts a connection, the process exits or
301
- * the timeout passes.
302
- *
303
- * @param {number} port The port
304
- * @param {{ name: string, pid: number, log: string }} record The process that must listen
305
- * @param {number} timeoutMs How long to wait
306
- * @returns {Promise<void>} Resolves once it listens
307
- * @throws When the process exits first or the timeout passes, naming its log
308
- */
309
- export async function waitForPort(port, record, timeoutMs) {
310
- const deadline = Date.now() + timeoutMs;
311
- while (Date.now() < deadline) {
312
- if (await accepts(port)) return;
313
- if (!isAlive(record.pid)) break;
314
- await sleep(POLL_MS);
315
- }
316
- throw new Error(
317
- `${record.name} did not listen on ${port}; see ${record.log}`,
318
- );
319
- }
320
-
321
- /**
322
- * Polls until the process itself listens on the port, so a port another
323
- * program took after it was picked is not mistaken for ours.
324
- *
325
- * @param {number} port The port
326
- * @param {{ name: string, pid: number, log: string }} record The process that must listen
327
- * @param {number} timeoutMs How long to wait
328
- * @returns {Promise<void>} Resolves once the process listens
329
- * @throws When it exits first (the port was taken) or the timeout passes
330
- */
331
- export async function waitForOwnPort(port, record, timeoutMs) {
332
- if (listenersOf(port) === null) return waitForPort(port, record, timeoutMs);
333
- const deadline = Date.now() + timeoutMs;
334
- while (Date.now() < deadline && isAlive(record.pid)) {
335
- if (listenersOf(port).includes(record.pid)) return;
336
- await sleep(POLL_MS);
337
- }
338
- throw new Error(
339
- `${record.name} does not listen on ${port}; see ${record.log}`,
340
- );
341
- }
342
-
343
258
  function procEntries() {
344
259
  try {
345
260
  return readdirSync("/proc").filter((entry) => /^\d+$/.test(entry));
package/e2e/run-copy.mjs CHANGED
@@ -34,7 +34,7 @@ function shadowLevel(real, shadow, ...keep) {
34
34
  /**
35
35
  * A `node_modules` that is `modules` with `@antelopejs/dms-frontend` replaced
36
36
  * by the renderer checkout and no `.cache`, every other entry linked to the
37
- * original.
37
+ * original. Without `modules`, it holds only the renderer.
38
38
  *
39
39
  * @param {string} modules The playground's installed modules
40
40
  * @param {string} shadow The run's `node_modules`
@@ -42,11 +42,11 @@ function shadowLevel(real, shadow, ...keep) {
42
42
  */
43
43
  export function linkRenderer(modules, shadow, renderer) {
44
44
  const scope = "@antelopejs";
45
- shadowLevel(modules, shadow, scope, MODULES_CACHE);
45
+ if (existsSync(modules)) shadowLevel(modules, shadow, scope, MODULES_CACHE);
46
46
  const scoped = join(modules, scope);
47
47
  const shadowScope = join(shadow, scope);
48
48
  if (existsSync(scoped)) shadowLevel(scoped, shadowScope, "dms-frontend");
49
- else mkdirSync(shadowScope);
49
+ else mkdirSync(shadowScope, { recursive: true });
50
50
  symlinkSync(renderer, join(shadowScope, "dms-frontend"));
51
51
  }
52
52
 
@@ -59,6 +59,8 @@ export function linkRenderer(modules, shadow, renderer) {
59
59
  * the playground's but `.cache`, where a backend writes its MCP credential
60
60
  * and its packed modules, so that folder belongs to the run too; and
61
61
  * `@antelopejs/dms-frontend` is the `renderer` checkout when there is one.
62
+ * A playground with no `node_modules` of its own gets none, unless it has a
63
+ * `renderer`, and resolves its modules from the linked levels above it.
62
64
  *
63
65
  * @param {string} playground The playground folder
64
66
  * @param {string} checkout The checkout root, or the module folder outside one
@@ -81,6 +83,8 @@ export function layOutCopy(playground, checkout, root, renderer) {
81
83
  });
82
84
  const modules = join(playground, "node_modules");
83
85
  if (renderer) linkRenderer(modules, join(shadow, "node_modules"), renderer);
84
- else shadowLevel(modules, join(shadow, "node_modules"), MODULES_CACHE);
86
+ else if (existsSync(modules)) {
87
+ shadowLevel(modules, join(shadow, "node_modules"), MODULES_CACHE);
88
+ }
85
89
  return shadow;
86
90
  }
package/e2e/stack.mjs CHANGED
@@ -21,9 +21,8 @@ import {
21
21
  runToEnd,
22
22
  startDetached,
23
23
  stopRecorded,
24
- waitForOk,
25
- waitForOwnPort,
26
24
  } from "./processes.mjs";
25
+ import { waitForBackend, waitForDashboard, waitForOwnPort } from "./waits.mjs";
27
26
  import {
28
27
  backendsFolder,
29
28
  createRunFolders,
@@ -333,21 +332,6 @@ export function liveBackends(state) {
333
332
  });
334
333
  }
335
334
 
336
- /**
337
- * Waits until a backend answers `/api/onboarding/informations` on its own port.
338
- *
339
- * @param {import("./run-state.mjs").ServerRecord} backend The backend
340
- * @returns {Promise<void>} Resolves once it answers 200
341
- * @throws When it exits first or the timeout passes, naming its log
342
- */
343
- export function waitForBackend(backend) {
344
- return waitForOk(
345
- `http://127.0.0.1:${backend.port}/api/onboarding/informations`,
346
- backend,
347
- READY_TIMEOUT_MS,
348
- );
349
- }
350
-
351
335
  /**
352
336
  * Starts the run's backend on `state.database`, from the run's build or
353
337
  * `build`, and points the API at it once it answers.
@@ -496,7 +480,7 @@ async function buildAndStart(state, useCache) {
496
480
  await timed(state, "frontend-start", async () => {
497
481
  const frontend = startDetached(frontendSpec(state));
498
482
  record(state, { ...frontend, port: state.webPort });
499
- await waitForOk(`${state.webUrl}/dms-preview`, frontend, READY_TIMEOUT_MS);
483
+ await waitForDashboard(state, frontend);
500
484
  assertFrontendBound(frontend);
501
485
  });
502
486
  await recordDashboardModules(state);
package/e2e/start.mjs CHANGED
@@ -49,21 +49,30 @@ export async function targetOf(options, cwd) {
49
49
  }
50
50
 
51
51
  /**
52
- * Starts the stack of a run: with `prepare`, the journeys config's install
53
- * and build commands first, then the stack on its playground and renderer.
52
+ * Runs the journeys config's install and build commands when `options`
53
+ * asks for them.
54
+ *
55
+ * @param {StartOptions} options How the runs start
56
+ * @param {string} cwd Where the runs start from, which finds the journeys config
57
+ * @returns {Promise<import("./timing.mjs").TimingEntry[]>} The timings of the commands, none when it ran nothing
58
+ */
59
+ async function prepareRuns(options, cwd) {
60
+ if (!options.prepare) return [];
61
+ const config = await loadSuiteConfig(cwd, options.config);
62
+ return runPrepare(config, config.repo);
63
+ }
64
+
65
+ /**
66
+ * Starts the stack of a run on its playground and renderer, the journeys
67
+ * config's commands already run.
54
68
  *
55
69
  * @param {StartOptions} options How to start it
70
+ * @param {import("./timing.mjs").TimingEntry[]} prepared The timings of the commands, which the run records
56
71
  * @param {string} cwd Where the run starts from, which finds the journeys config
57
72
  * @returns {Promise<import("./run-state.mjs").RunState>} The ready run
58
73
  */
59
- export async function startStack(options, cwd) {
60
- const { prepare, config: journeysConfig, ...upOptions } = options;
61
- /** @type {import("./timing.mjs").TimingEntry[]} */
62
- let prepared = [];
63
- if (prepare) {
64
- const config = await loadSuiteConfig(cwd, journeysConfig);
65
- prepared = runPrepare(config, config.repo);
66
- }
74
+ export async function startStack(options, prepared, cwd) {
75
+ const { prepare: _prepare, config: _journeysConfig, ...upOptions } = options;
67
76
  const state = await up({
68
77
  ...upOptions,
69
78
  ...(await targetOf(options, cwd)),
@@ -110,22 +119,23 @@ async function stopRuns(dirs) {
110
119
  /**
111
120
  * Starts `count` runs of the checkout's playground, each with its own
112
121
  * playground copy, ports, MongoDB, mail sink, backends and dashboard, for
113
- * the workers of one suite to drive one each. The first runs the journeys
114
- * config's prepare commands as `options` asks; the others start once it is
115
- * ready, together, without them, so their dashboards come from the build
116
- * cache the first one filled. `stop` stops them all, and from the moment
117
- * the first is ready a SIGINT or SIGTERM to this process stops every run
118
- * started so far, then ends the process by that signal.
122
+ * the workers of one suite to drive one each. The journeys config's prepare
123
+ * commands run first, once, as `options` asks; then every run starts at the
124
+ * same time. `stop` stops them all, and from the moment the runs start a
125
+ * SIGINT or SIGTERM to this process stops every run ready so far, then
126
+ * ends the process by that signal.
119
127
  *
120
128
  * @param {RunOptions} options How to start them
121
129
  * @param {number} count How many, at least 1
122
- * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, and what stops them
123
- * @throws When a run fails to start; every run it started is stopped first
130
+ * @returns {Promise<{ runs: import("./run-state.mjs").RunState[], stop: () => Promise<void> }>} The ready runs, one per worker, and what stops them
131
+ * @throws When a run fails to start; every run that started is stopped first
124
132
  */
125
133
  export async function startRuns(options, count) {
126
134
  const cwd = process.cwd();
127
- const first = await startStack(startOptions(options, cwd), cwd);
128
- const dirs = [first.dir];
135
+ const start = startOptions(options, cwd);
136
+ const prepared = await prepareRuns(start, cwd);
137
+ /** @type {string[]} */
138
+ const dirs = [];
129
139
  const onSignal = (/** @type {NodeJS.Signals} */ signal) => {
130
140
  release();
131
141
  const reraise = () => process.kill(process.pid, signal);
@@ -135,29 +145,23 @@ export async function startRuns(options, count) {
135
145
  for (const signal of STOP_SIGNALS) process.off(signal, onSignal);
136
146
  };
137
147
  for (const signal of STOP_SIGNALS) process.on(signal, onSignal);
138
- const others = await Promise.allSettled(
139
- Array.from({ length: count - 1 }, async () => {
140
- const run = await startStack(
141
- startOptions({ ...options, prepare: false }, cwd),
142
- cwd,
143
- );
148
+ const started = await Promise.allSettled(
149
+ Array.from({ length: count }, async (_, index) => {
150
+ const run = await startStack(start, index === 0 ? prepared : [], cwd);
144
151
  dirs.push(run.dir);
145
152
  return run;
146
153
  }),
147
154
  );
148
- const failed = others.find((other) => other.status === "rejected");
155
+ const failed = started.find((run) => run.status === "rejected");
149
156
  if (failed) {
150
157
  release();
151
158
  await stopRuns(dirs);
152
159
  throw failed.reason;
153
160
  }
154
161
  return {
155
- runs: [
156
- first,
157
- ...others.flatMap((other) =>
158
- other.status === "fulfilled" ? [other.value] : [],
159
- ),
160
- ],
162
+ runs: started.flatMap((run) =>
163
+ run.status === "fulfilled" ? [run.value] : [],
164
+ ),
161
165
  stop: () => {
162
166
  release();
163
167
  return stopRuns(dirs);
package/e2e/waits.mjs ADDED
@@ -0,0 +1,138 @@
1
+ import { createConnection } from "node:net";
2
+ import { setTimeout as sleep } from "node:timers/promises";
3
+ import { isAlive } from "./identity.mjs";
4
+ import { descendantsOf, listenersOf } from "./processes.mjs";
5
+
6
+ const POLL_MS = 500;
7
+ const READY_POLL_MS = 100;
8
+ const PROBE_TIMEOUT_MS = 3_000;
9
+ const READY_TIMEOUT_MS = 180_000;
10
+
11
+ /**
12
+ * The status of one GET, or `null` when nothing answered.
13
+ *
14
+ * @param {string} url The URL
15
+ * @returns {Promise<number | null>} The HTTP status
16
+ */
17
+ export async function probe(url) {
18
+ try {
19
+ const response = await fetch(url, {
20
+ signal: AbortSignal.timeout(PROBE_TIMEOUT_MS),
21
+ });
22
+ await response.body?.cancel();
23
+ return response.status;
24
+ } catch {
25
+ return null;
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Polls `url` until it answers 200, the process exits or the timeout passes.
31
+ *
32
+ * @param {string} url The readiness URL
33
+ * @param {{ pid: number, log: string }} record The process that must serve it
34
+ * @param {number} timeoutMs How long to wait
35
+ * @returns {Promise<void>} Resolves once ready
36
+ * @throws When the process exits first or the timeout passes, naming its log
37
+ */
38
+ export async function waitForOk(url, record, timeoutMs) {
39
+ const deadline = Date.now() + timeoutMs;
40
+ while (Date.now() < deadline) {
41
+ if (!isAlive(record.pid)) {
42
+ throw new Error(`${url}: the process exited first; see ${record.log}`);
43
+ }
44
+ if ((await probe(url)) === 200) return;
45
+ await sleep(READY_POLL_MS);
46
+ }
47
+ throw new Error(
48
+ `${url} did not answer 200 in ${timeoutMs} ms; see ${record.log}`,
49
+ );
50
+ }
51
+
52
+ /** @param {number} port */
53
+ function accepts(port) {
54
+ return new Promise((resolve) => {
55
+ const socket = createConnection({ host: "127.0.0.1", port });
56
+ socket.once("connect", () => {
57
+ socket.end();
58
+ resolve(true);
59
+ });
60
+ socket.once("error", () => resolve(false));
61
+ });
62
+ }
63
+
64
+ /**
65
+ * Polls a loopback port until it accepts a connection, the process exits or
66
+ * the timeout passes.
67
+ *
68
+ * @param {number} port The port
69
+ * @param {{ name: string, pid: number, log: string }} record The process that must listen
70
+ * @param {number} timeoutMs How long to wait
71
+ * @returns {Promise<void>} Resolves once it listens
72
+ * @throws When the process exits first or the timeout passes, naming its log
73
+ */
74
+ export async function waitForPort(port, record, timeoutMs) {
75
+ const deadline = Date.now() + timeoutMs;
76
+ while (Date.now() < deadline) {
77
+ if (await accepts(port)) return;
78
+ if (!isAlive(record.pid)) break;
79
+ await sleep(POLL_MS);
80
+ }
81
+ throw new Error(
82
+ `${record.name} did not listen on ${port}; see ${record.log}`,
83
+ );
84
+ }
85
+
86
+ /**
87
+ * Polls until the process or one it started listens on the port, so a port
88
+ * another program took after it was picked is not mistaken for ours.
89
+ *
90
+ * @param {number} port The port
91
+ * @param {{ name: string, pid: number, log: string }} record The process that must listen
92
+ * @param {number} timeoutMs How long to wait
93
+ * @returns {Promise<void>} Resolves once the process listens
94
+ * @throws When it exits first (the port was taken) or the timeout passes
95
+ */
96
+ export async function waitForOwnPort(port, record, timeoutMs) {
97
+ if (listenersOf(port) === null) return waitForPort(port, record, timeoutMs);
98
+ const deadline = Date.now() + timeoutMs;
99
+ while (Date.now() < deadline && isAlive(record.pid)) {
100
+ const own = new Set([record.pid, ...descendantsOf([record.pid])]);
101
+ if (listenersOf(port)?.some((pid) => own.has(pid))) return;
102
+ await sleep(READY_POLL_MS);
103
+ }
104
+ throw new Error(
105
+ `${record.name} does not listen on ${port}; see ${record.log}`,
106
+ );
107
+ }
108
+
109
+ /**
110
+ * Waits until a backend listens on its own port and answers
111
+ * `/api/onboarding/informations` there.
112
+ *
113
+ * @param {import("./run-state.mjs").ServerRecord} backend The backend
114
+ * @returns {Promise<void>} Resolves once it answers 200
115
+ * @throws When it exits first, another process holds its port or the timeout passes, naming its log
116
+ */
117
+ export async function waitForBackend(backend) {
118
+ await waitForOwnPort(backend.port, backend, READY_TIMEOUT_MS);
119
+ await waitForOk(
120
+ `http://127.0.0.1:${backend.port}/api/onboarding/informations`,
121
+ backend,
122
+ READY_TIMEOUT_MS,
123
+ );
124
+ }
125
+
126
+ /**
127
+ * Waits until the run's dashboard listens on the run's web port and answers
128
+ * `/dms-preview` there.
129
+ *
130
+ * @param {Pick<import("./run-state.mjs").RunState, "webPort" | "webUrl">} state The run
131
+ * @param {import("./run-state.mjs").ProcessRecord} frontend The dashboard's process
132
+ * @returns {Promise<void>} Resolves once it answers 200
133
+ * @throws When it exits first, another process holds its port or the timeout passes, naming its log
134
+ */
135
+ export async function waitForDashboard(state, frontend) {
136
+ await waitForOwnPort(state.webPort, frontend, READY_TIMEOUT_MS);
137
+ await waitForOk(`${state.webUrl}/dms-preview`, frontend, READY_TIMEOUT_MS);
138
+ }
@@ -80,7 +80,7 @@
80
80
  "devDependencies": {
81
81
  "@antelopejs/core": "~1.24.5",
82
82
  "@antelopejs/dms-frontend": ">=0.11.11 <0.12.0",
83
- "@antelopejs/tooling-configs": ">=0.10.12 <0.11.0",
83
+ "@antelopejs/tooling-configs": ">=0.10.14 <0.11.0",
84
84
  "@inertiajs/vue3": "^3.7.0",
85
85
  "@nuxt/eslint-config": "^1.17.0",
86
86
  "@nuxt/ui": "4.10.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms",
3
- "version": "0.25.0",
3
+ "version": "0.25.2",
4
4
  "description": "AntelopeJS DMS. Plug in your PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -120,7 +120,7 @@
120
120
  "@antelopejs/mysql": ">=0.2.7 <0.3.0",
121
121
  "@antelopejs/postgres": ">=0.4.3 <0.5.0",
122
122
  "@antelopejs/rethinkdb": "~1.10.6",
123
- "@antelopejs/tooling-configs": ">=0.10.12 <0.11.0",
123
+ "@antelopejs/tooling-configs": ">=0.10.14 <0.11.0",
124
124
  "@playwright/test": "~1.65.0",
125
125
  "@types/archiver": "^6.0.4",
126
126
  "@types/chai": "^5.0.0",
@@ -211,7 +211,7 @@
211
211
  "optional": true
212
212
  }
213
213
  },
214
- "gitHead": "f3f8282f5834ebe408f0ce6f950a3f1b53f227ef",
214
+ "gitHead": "120b32596b6e0a703e8b7297fbc4be04ace4a0da",
215
215
  "scripts": {
216
216
  "build": "pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder build && rimraf dist && antelopejs-tsc && tsc-alias && tsc -p e2e/tsconfig.types.json",
217
217
  "dev": "ajs project run --inspect -w -p playground",