@zq-silk/yui 0.15.5 → 0.15.6
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.
|
@@ -76,8 +76,9 @@ export class RuntimeLaunchCoordinator {
|
|
|
76
76
|
if (request.owner.scope === "global" && request.managedWorkspace !== undefined) {
|
|
77
77
|
throw new Error("A global runtime cannot use a Task ManagedWorkspace.");
|
|
78
78
|
}
|
|
79
|
+
let currentRequest = request;
|
|
79
80
|
const assertLaunchCurrent = () => {
|
|
80
|
-
this.#assertCurrent?.(
|
|
81
|
+
this.#assertCurrent?.(currentRequest);
|
|
81
82
|
assertCurrent?.();
|
|
82
83
|
};
|
|
83
84
|
const proposedGenerationId = requireText(this.#createGenerationId(), "Launch generation id");
|
|
@@ -155,8 +156,20 @@ export class RuntimeLaunchCoordinator {
|
|
|
155
156
|
throw new Error("Runtime host reported its pre-start launch fence more than once.");
|
|
156
157
|
}
|
|
157
158
|
validateRuntimeLaunchPreflight(preflight, request, runtimeGenerationId);
|
|
159
|
+
this.reservations.confirmRuntimeLaunchReservation({
|
|
160
|
+
owner: request.owner,
|
|
161
|
+
runtimeGenerationId
|
|
162
|
+
}, assertLaunchCurrent);
|
|
158
163
|
preflightObserved = true;
|
|
159
164
|
beforeHostStart?.(preflight);
|
|
165
|
+
// The pre-start persistence callback hands the fixed native Session to
|
|
166
|
+
// this reserved activation. From here on, fence against that exact new
|
|
167
|
+
// identity, not the historical Host we originally set out to restore.
|
|
168
|
+
// Do not accept both identities: a later change back is stale as well.
|
|
169
|
+
if (request.mode === "resume" && request.hostActivationId !== undefined) {
|
|
170
|
+
currentRequest = { ...request, hostActivationId: runtimeGenerationId };
|
|
171
|
+
}
|
|
172
|
+
assertLaunchCurrent();
|
|
160
173
|
};
|
|
161
174
|
let binding;
|
|
162
175
|
try {
|
|
@@ -257,7 +270,7 @@ export class RuntimeLaunchCoordinator {
|
|
|
257
270
|
throw error;
|
|
258
271
|
}
|
|
259
272
|
if (reusedConfirmedRunningHost && binding.hostCreated === true) {
|
|
260
|
-
await this.#compensateStartedHost(request.owner, binding, runtimeGenerationId, runtimeIsolation, new Error(`Runtime host was recreated while recovering an existing generation: ${request.owner.roleName}.`));
|
|
273
|
+
await this.#compensateStartedHost(request.owner, binding, runtimeGenerationId, runtimeIsolation, reusedConfirmedRunningHost, new Error(`Runtime host was recreated while recovering an existing generation: ${request.owner.roleName}.`));
|
|
261
274
|
}
|
|
262
275
|
try {
|
|
263
276
|
assertLaunchCurrent();
|
|
@@ -282,7 +295,7 @@ export class RuntimeLaunchCoordinator {
|
|
|
282
295
|
}
|
|
283
296
|
}
|
|
284
297
|
catch (error) {
|
|
285
|
-
await this.#compensateStartedHost(request.owner, binding, runtimeGenerationId, runtimeIsolation, error);
|
|
298
|
+
await this.#compensateStartedHost(request.owner, binding, runtimeGenerationId, runtimeIsolation, reusedConfirmedRunningHost, error);
|
|
286
299
|
}
|
|
287
300
|
return binding;
|
|
288
301
|
}
|
|
@@ -317,7 +330,14 @@ export class RuntimeLaunchCoordinator {
|
|
|
317
330
|
return;
|
|
318
331
|
this.#requireCleanup(request.owner);
|
|
319
332
|
}
|
|
320
|
-
async #compensateStartedHost(owner, binding, runtimeGenerationId, runtimeIsolation, cause) {
|
|
333
|
+
async #compensateStartedHost(owner, binding, runtimeGenerationId, runtimeIsolation, reusedConfirmedRunningHost, cause) {
|
|
334
|
+
if (reusedConfirmedRunningHost && binding.hostCreated !== true) {
|
|
335
|
+
// Reattaching an existing activation gives this launch no ownership of
|
|
336
|
+
// it. A fresh activation inside a persistent Host is different: this
|
|
337
|
+
// launch still owns its startup and isolation cleanup even when the
|
|
338
|
+
// physical Host did not need to be created.
|
|
339
|
+
throw new RuntimeLaunchStateChangedError(`Runtime launch state changed while reusing a Host: ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
340
|
+
}
|
|
321
341
|
try {
|
|
322
342
|
await this.host.stop(binding);
|
|
323
343
|
}
|