@mostra/runtime 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +2 -2
- package/dist/bin.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/{instance-Da8UG_Qd.js → instance-BfGOToHo.js} +16 -3
- package/dist/{instance-Da8UG_Qd.js.map → instance-BfGOToHo.js.map} +1 -1
- package/package.json +16 -16
- package/src/bin.ts +12 -1
- package/src/dev/index.ts +26 -4
- package/src/instance/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mostra/runtime",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The Mostra runtime: the supervisor that owns a home, its ledger, its child processes and the host protocol server (mostra-runtime host|daemon).",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "The Mostra Authors",
|
|
@@ -34,38 +34,38 @@
|
|
|
34
34
|
"provenance": true
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@hono/node-server": "2.1.
|
|
37
|
+
"@hono/node-server": "2.1.5",
|
|
38
38
|
"@mdx-js/mdx": "3.1.1",
|
|
39
|
-
"@mostra/protocol": "0.6.
|
|
39
|
+
"@mostra/protocol": "0.6.1",
|
|
40
40
|
"@tailwindcss/vite": "4.3.3",
|
|
41
|
-
"@vitejs/plugin-react": "6.1.
|
|
41
|
+
"@vitejs/plugin-react": "6.1.2",
|
|
42
42
|
"better-sqlite3": "13.0.3",
|
|
43
43
|
"hono": "4.13.13",
|
|
44
|
-
"ignore": "7.0.
|
|
45
|
-
"oxc-parser": "0.
|
|
46
|
-
"pnpm": "10.34.
|
|
44
|
+
"ignore": "7.0.13",
|
|
45
|
+
"oxc-parser": "0.155.0",
|
|
46
|
+
"pnpm": "10.34.7",
|
|
47
47
|
"remark-frontmatter": "5.0.0",
|
|
48
48
|
"remark-gfm": "4.0.1",
|
|
49
49
|
"semver": "7.8.5",
|
|
50
50
|
"tailwindcss": "4.3.3",
|
|
51
51
|
"typescript": "7.0.2",
|
|
52
|
-
"vite": "8.3.
|
|
52
|
+
"vite": "8.3.4",
|
|
53
53
|
"yaml": "2.9.1",
|
|
54
|
-
"zod": "4.6.
|
|
54
|
+
"zod": "4.6.7"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@mostra/shell": "0.6.
|
|
57
|
+
"@mostra/shell": "0.6.1",
|
|
58
58
|
"@mostra/tools": "0.0.0",
|
|
59
|
-
"@mostra/verify": "0.6.
|
|
59
|
+
"@mostra/verify": "0.6.1",
|
|
60
60
|
"@mostra/warm": "0.0.0",
|
|
61
|
-
"@mostra/worker": "0.6.
|
|
61
|
+
"@mostra/worker": "0.6.1",
|
|
62
62
|
"@types/better-sqlite3": "9.6.0",
|
|
63
|
-
"@types/node": "24.19.
|
|
63
|
+
"@types/node": "24.19.2",
|
|
64
64
|
"@types/semver": "7.8.0",
|
|
65
65
|
"fast-check": "4.10.2",
|
|
66
|
-
"playwright": "1.64.
|
|
67
|
-
"tsdown": "0.23.
|
|
68
|
-
"vitest": "5.0.
|
|
66
|
+
"playwright": "1.64.1",
|
|
67
|
+
"tsdown": "0.23.1",
|
|
68
|
+
"vitest": "5.0.5"
|
|
69
69
|
},
|
|
70
70
|
"keywords": [
|
|
71
71
|
"mostra",
|
package/src/bin.ts
CHANGED
|
@@ -103,7 +103,18 @@ function handleSignals(instance: Instance): void {
|
|
|
103
103
|
process.on("exit", () => instance.processes.killAll());
|
|
104
104
|
process.on("uncaughtException", (error) => {
|
|
105
105
|
mirror(`${JSON.stringify({ level: "error", event: "uncaught", message: error.message })}\n`);
|
|
106
|
-
|
|
106
|
+
// The home's log keeps what failed and where, so a failure nobody watched stderr for still
|
|
107
|
+
// names its cause (#35: an instance that ended with only "uncaught exception" in its log).
|
|
108
|
+
void instance.stop(
|
|
109
|
+
"uncaught exception",
|
|
110
|
+
EXIT.failure,
|
|
111
|
+
createDiagnostic("MOSTRA_HOST_INTERNAL_ERROR", {
|
|
112
|
+
message: (error instanceof Error
|
|
113
|
+
? (error.stack ?? `${error.name}: ${error.message}`)
|
|
114
|
+
: String(error)
|
|
115
|
+
).slice(0, 8192),
|
|
116
|
+
}),
|
|
117
|
+
);
|
|
107
118
|
setTimeout(() => process.exit(EXIT.failure), 15_000).unref();
|
|
108
119
|
});
|
|
109
120
|
}
|
package/src/dev/index.ts
CHANGED
|
@@ -405,15 +405,34 @@ export function createDev(options: DevOptions): Dev {
|
|
|
405
405
|
);
|
|
406
406
|
|
|
407
407
|
// The session ends with its connection (D140 item 12), from the first moment: a connection
|
|
408
|
-
// that closes while packages resolve or the dev server starts leaves nothing running.
|
|
409
|
-
|
|
408
|
+
// that closes while packages resolve or the dev server starts leaves nothing running. While
|
|
409
|
+
// the session starts, its start owns the cleanup: a close marks it, and the start stops what
|
|
410
|
+
// it started at its next step, then removes the session's directory. A close that removed
|
|
411
|
+
// the directory at once did so under a dev server still writing into it (its staging files,
|
|
412
|
+
// its `node_modules` link, Vite's cache), the removal failed on the files it wrote, and the
|
|
413
|
+
// failure took the whole instance down (#35). Once started, a close stops the session, and
|
|
414
|
+
// a stop that fails is logged: it never ends the instance.
|
|
415
|
+
let starting = true;
|
|
416
|
+
connection.signal.addEventListener(
|
|
417
|
+
"abort",
|
|
418
|
+
() => {
|
|
419
|
+
if (starting) closed = true;
|
|
420
|
+
else stop().catch((error: unknown) => log.warn("dev.stop_failed", { sessionId, error }));
|
|
421
|
+
},
|
|
422
|
+
{ once: true },
|
|
423
|
+
);
|
|
410
424
|
try {
|
|
411
425
|
if (connection.signal.aborted) throw abandoned();
|
|
426
|
+
// A close stops the start at its next step, before resolving packages least of all, which
|
|
427
|
+
// may install under the shared gate (the Opus review of MT-02).
|
|
412
428
|
await sync();
|
|
429
|
+
if (closed) throw abandoned();
|
|
413
430
|
const described = await describe();
|
|
431
|
+
if (closed) throw abandoned();
|
|
414
432
|
manifestKey = JSON.stringify(described.manifest);
|
|
415
433
|
nodeModules = await resolve(described.manifest.id);
|
|
416
434
|
artifactId = described.artifactId;
|
|
435
|
+
if (closed) throw abandoned();
|
|
417
436
|
child = await startChild(described);
|
|
418
437
|
if (closed) throw abandoned();
|
|
419
438
|
const upstream = (): { port: number; secret: string } | undefined =>
|
|
@@ -438,13 +457,16 @@ export function createDev(options: DevOptions): Dev {
|
|
|
438
457
|
...(params.port !== undefined ? { shellPort: params.port } : {}),
|
|
439
458
|
});
|
|
440
459
|
if (closed) throw abandoned();
|
|
460
|
+
// Nothing below awaits, so no close can fall between this and the session's registration.
|
|
461
|
+
starting = false;
|
|
441
462
|
sandbox.onSubmission((results) => notify("submission", { results }));
|
|
442
463
|
} catch (error) {
|
|
443
464
|
closed = true;
|
|
444
465
|
sessions.delete(sessionId);
|
|
445
|
-
//
|
|
446
|
-
//
|
|
466
|
+
// Every step that started something has returned, so nothing writes into the session's
|
|
467
|
+
// directory once its dev server and sandbox stopped.
|
|
447
468
|
await release();
|
|
469
|
+
if (connection.signal.aborted) log.info("dev.stopped", { sessionId });
|
|
448
470
|
throw error;
|
|
449
471
|
}
|
|
450
472
|
|
package/src/instance/index.ts
CHANGED
|
@@ -844,7 +844,7 @@ async function assemble(home: OwnedHome, options: StartInstanceOptions): Promise
|
|
|
844
844
|
stopped,
|
|
845
845
|
stop(reason, exitCode = 0, diagnostic) {
|
|
846
846
|
stopping ??= (async () => {
|
|
847
|
-
log.info("instance.stopping", { reason, exitCode });
|
|
847
|
+
log.info("instance.stopping", { reason, exitCode, ...(diagnostic ? { diagnostic } : {}) });
|
|
848
848
|
idle?.stop();
|
|
849
849
|
stopWatchingPublishes();
|
|
850
850
|
live.stop();
|