@quolu/lattice 0.12.31 → 0.12.32

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quolu/lattice",
3
- "version": "0.12.31",
3
+ "version": "0.12.32",
4
4
  "description": "Lattice — phase-aware TODO graph compiler and conflict-aware orchestration runtime",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -272,7 +272,7 @@ export async function writeTodoDashboardDaemonDescriptor({ port, env = process.e
272
272
  }
273
273
 
274
274
  export async function ensureTodoDashboardDaemon({ env = process.env, spawnDaemon = spawn,
275
- signalProcess = process.kill, isProcessAlive = processIsAlive, startupTimeoutMs = 4_000,
275
+ signalProcess = process.kill, isProcessAlive = processIsAlive, startupTimeoutMs = 120_000,
276
276
  legacyStopTimeoutMs = 3_000, replacementIsProcessAlive = processIsAlive,
277
277
  attestationTimeoutMs = 2_000 } = {}) {
278
278
  const refs = paths(env);
@@ -299,11 +299,20 @@ export async function ensureTodoDashboardDaemon({ env = process.env, spawnDaemon
299
299
  env: { ...env, LATTICE_DASHBOARD_RUNTIME_DIR: refs.root, LATTICE_DASHBOARD_PORT: String(port) },
300
300
  });
301
301
  child.unref();
302
+ // 起動待ちの終わりを固定秒数で決めない。それは機械の速さの見積りになり、遅い側
303
+ // へ外すとpublish済みのcodeを載せたdaemonへ入れ替われず、公開面が古いまま取り
304
+ // 残される。daemonはdescriptorを書く前に登録済み全projectのstoreを読むので、
305
+ // 起動時間はproject数とstore規模に比例する(実測: 8 projectで約51秒)。
306
+ // 待つのはspawnした子が生きている間だけとし、死んだら即座に諦める。
307
+ // startupTimeoutMsは無反応な子に対するbackstopであって起動時間の上限ではない。
302
308
  const deadline = Date.now() + startupTimeoutMs;
303
309
  while (Date.now() < deadline) {
304
310
  await new Promise((resolve) => setTimeout(resolve, 50));
305
311
  const descriptor = await readJson(refs.descriptor, null);
306
- if (await daemonHealthy(descriptor) && descriptor.pid !== legacy?.pid) {
312
+ const healthy = await daemonHealthy(descriptor);
313
+ if (!healthy && typeof child.pid === 'number'
314
+ && !await replacementIsProcessAlive(child.pid)) break;
315
+ if (healthy && descriptor.pid !== legacy?.pid) {
307
316
  if (legacy !== null) {
308
317
  try {
309
318
  await stopAttestedLegacyDaemon(legacy, {