@camstack/server 1.2.303 → 1.2.305
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.
|
@@ -55,6 +55,7 @@ const package_dir_utils_1 = require("./package-dir-utils");
|
|
|
55
55
|
const forked_custom_actions_js_1 = require("./forked-custom-actions.js");
|
|
56
56
|
const prune_misplaced_addons_js_1 = require("./prune-misplaced-addons.js");
|
|
57
57
|
const runner_convergence_1 = require("./runner-convergence");
|
|
58
|
+
const runner_serialization_1 = require("./runner-serialization");
|
|
58
59
|
const runner_spawn_fanout_js_1 = require("./runner-spawn-fanout.js");
|
|
59
60
|
/**
|
|
60
61
|
* Decide whether an in-memory addon entry should be evicted because it is no
|
|
@@ -3100,9 +3101,27 @@ class AddonRegistryService {
|
|
|
3100
3101
|
throw new Error(`initializeAddonGroup("${runnerId}") requires at least one addon`);
|
|
3101
3102
|
}
|
|
3102
3103
|
try {
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3104
|
+
// Serialized on the SAME key as `ensureForkedRunner`. This is the boot
|
|
3105
|
+
// path, and a boot spawn racing the restart a deploy fires for itself is
|
|
3106
|
+
// exactly how two runners started in the same second on 2026-09-17 —
|
|
3107
|
+
// with no manual restart anywhere. Covering only the converge left the
|
|
3108
|
+
// same race with a smaller window, and it lost the very next deploy.
|
|
3109
|
+
await this.serializeRunner(runnerId, async () => {
|
|
3110
|
+
try {
|
|
3111
|
+
await this.broker.call('$process.spawnRunner', { runnerId, addons });
|
|
3112
|
+
}
|
|
3113
|
+
catch (err) {
|
|
3114
|
+
// Losing the race is not a failure, and this method's own docblock
|
|
3115
|
+
// already promised so: "No-op when the runner is already running".
|
|
3116
|
+
// Unserialized the loser almost never got here — it spawned a SECOND
|
|
3117
|
+
// runner instead, which is the defect. Serializing makes the loser
|
|
3118
|
+
// reliable, so the promise has to be kept rather than documented.
|
|
3119
|
+
if (!/already running/i.test((0, types_1.errMsg)(err)))
|
|
3120
|
+
throw err;
|
|
3121
|
+
this.logger.info('initializeAddonGroup: runner already running — nothing to spawn', {
|
|
3122
|
+
meta: { runnerId, addonIds: addons.map((a) => a.addonId) },
|
|
3123
|
+
});
|
|
3124
|
+
}
|
|
3106
3125
|
});
|
|
3107
3126
|
}
|
|
3108
3127
|
catch (err) {
|
|
@@ -3167,6 +3186,12 @@ class AddonRegistryService {
|
|
|
3167
3186
|
* a group respawns the ENTIRE group (they share a process): the operator's
|
|
3168
3187
|
* "update one → respawn the whole group" invariant.
|
|
3169
3188
|
*/
|
|
3189
|
+
/**
|
|
3190
|
+
* One converge at a time per runner. See `runner-serialization.ts` for the
|
|
3191
|
+
* two live episodes this closes and why the lock inside `process-service`
|
|
3192
|
+
* could not.
|
|
3193
|
+
*/
|
|
3194
|
+
serializeRunner = (0, runner_serialization_1.createRunnerSerializer)();
|
|
3170
3195
|
async ensureForkedRunner(addonId, opts) {
|
|
3171
3196
|
const entry = this.addonEntries.get(addonId);
|
|
3172
3197
|
if (!entry?.declaration || !entry.addonDir) {
|
|
@@ -3188,43 +3213,52 @@ class AddonRegistryService {
|
|
|
3188
3213
|
Date.now() - (this.recentGroupRespawns.get(runnerId) ?? 0) < GROUP_RESPAWN_COALESCE_MS
|
|
3189
3214
|
? false
|
|
3190
3215
|
: opts.restart;
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
//
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3216
|
+
// EVERYTHING from here is one atomic unit per runner. The read decides what
|
|
3217
|
+
// to stop and what to spawn, so a second converge that reads before this
|
|
3218
|
+
// one has spawned decides to spawn too — and the child nobody tracks keeps
|
|
3219
|
+
// running. `process-service`'s own lock cannot see this: it makes each
|
|
3220
|
+
// action atomic, and the unit that matters is the sequence.
|
|
3221
|
+
return this.serializeRunner(runnerId, async () => {
|
|
3222
|
+
const running = await this.listRunnerProcesses();
|
|
3223
|
+
const plan = (0, runner_convergence_1.planRunnerConvergence)(runnerId, roster.map((r) => r.addonId), running, { restart: effectiveRestart });
|
|
3224
|
+
// 1. Tear down every stale/mismatched runner that hosts a roster member.
|
|
3225
|
+
for (const name of plan.stop) {
|
|
3226
|
+
await this.broker.call('$process.stop', { name }).catch((err) => {
|
|
3227
|
+
this.logger.warn('ensureForkedRunner: failed to stop stale runner (continuing)', {
|
|
3228
|
+
meta: { runnerId, stale: name, error: (0, types_1.errMsg)(err) },
|
|
3229
|
+
});
|
|
3198
3230
|
});
|
|
3199
|
-
});
|
|
3200
|
-
}
|
|
3201
|
-
// 2. Bring the target runner to the correct roster.
|
|
3202
|
-
if (plan.action === 'spawn') {
|
|
3203
|
-
await this.broker.call('$process.spawnRunner', { runnerId, addons: roster }).catch((err) => {
|
|
3204
|
-
// A concurrent path may have won the spawn race — treat "already
|
|
3205
|
-
// running" as success (idempotent), rethrow anything else.
|
|
3206
|
-
if (!/already running/i.test((0, types_1.errMsg)(err)))
|
|
3207
|
-
throw err;
|
|
3208
|
-
});
|
|
3209
|
-
this.recentGroupRespawns.set(runnerId, Date.now());
|
|
3210
|
-
}
|
|
3211
|
-
else if (plan.action === 'restart') {
|
|
3212
|
-
const res = (await this.broker.call('$process.restart', { name: runnerId }));
|
|
3213
|
-
if (!res.success) {
|
|
3214
|
-
throw new Error(`Process restart failed: ${res.reason ?? 'unknown'}`);
|
|
3215
3231
|
}
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3232
|
+
// 2. Bring the target runner to the correct roster.
|
|
3233
|
+
if (plan.action === 'spawn') {
|
|
3234
|
+
await this.broker
|
|
3235
|
+
.call('$process.spawnRunner', { runnerId, addons: roster })
|
|
3236
|
+
.catch((err) => {
|
|
3237
|
+
// A concurrent path may have won the spawn race — treat "already
|
|
3238
|
+
// running" as success (idempotent), rethrow anything else.
|
|
3239
|
+
if (!/already running/i.test((0, types_1.errMsg)(err)))
|
|
3240
|
+
throw err;
|
|
3241
|
+
});
|
|
3242
|
+
this.recentGroupRespawns.set(runnerId, Date.now());
|
|
3243
|
+
}
|
|
3244
|
+
else if (plan.action === 'restart') {
|
|
3245
|
+
const res = (await this.broker.call('$process.restart', { name: runnerId }));
|
|
3246
|
+
if (!res.success) {
|
|
3247
|
+
throw new Error(`Process restart failed: ${res.reason ?? 'unknown'}`);
|
|
3248
|
+
}
|
|
3249
|
+
this.recentGroupRespawns.set(runnerId, Date.now());
|
|
3250
|
+
}
|
|
3251
|
+
// 3. Bookkeeping for EVERY roster member. Mark each member initialized so
|
|
3252
|
+
// the in-process core-builtin boot passes skip them. The custom-action
|
|
3253
|
+
// catalogs are NOT touched here: the respawned runner describes them in
|
|
3254
|
+
// its post-init register frame and `applyChildCustomActions` replaces
|
|
3255
|
+
// whatever the previous incarnation registered (D444).
|
|
3256
|
+
for (const { addonId: memberId } of roster) {
|
|
3257
|
+
const memberEntry = this.addonEntries.get(memberId);
|
|
3258
|
+
if (memberEntry)
|
|
3259
|
+
memberEntry.initialized = true;
|
|
3260
|
+
}
|
|
3261
|
+
});
|
|
3228
3262
|
}
|
|
3229
3263
|
/**
|
|
3230
3264
|
* Apply the custom-action catalogs a UDS child DESCRIBED in its register
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRunnerSerializer = createRunnerSerializer;
|
|
4
|
+
function createRunnerSerializer() {
|
|
5
|
+
const tails = new Map();
|
|
6
|
+
return (runnerId, converge) => {
|
|
7
|
+
const previous = tails.get(runnerId) ?? Promise.resolve();
|
|
8
|
+
// `then(fn, fn)` so a rejected predecessor still lets the next one run.
|
|
9
|
+
const result = previous.then(converge, converge);
|
|
10
|
+
tails.set(runnerId, result.then(() => undefined, () => undefined));
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.305",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"@camstack/addon-auth": "1.2.115",
|
|
41
41
|
"@camstack/addon-decoder-nodeav": "1.2.108",
|
|
42
42
|
"@camstack/addon-notifiers": "1.2.112",
|
|
43
|
-
"@camstack/addon-pipeline": "1.2.
|
|
43
|
+
"@camstack/addon-pipeline": "1.2.252",
|
|
44
44
|
"@camstack/addon-pipeline-orchestrator": "1.2.214",
|
|
45
|
-
"@camstack/addon-post-analysis": "1.2.
|
|
45
|
+
"@camstack/addon-post-analysis": "1.2.256",
|
|
46
46
|
"@camstack/sdk": "1.2.111",
|
|
47
|
-
"@camstack/system": "1.2.
|
|
47
|
+
"@camstack/system": "1.2.247",
|
|
48
48
|
"@camstack/types": "1.2.205",
|
|
49
49
|
"@camstack/ui-library": "1.2.170",
|
|
50
50
|
"@fastify/compress": "^9.0.0",
|