ソースを参照

fix: skip unknown hooks in resolve/defer instead of throwing

Settler may reference hook IDs that were cleared by a previous
settlement or not yet created. Gracefully skip instead of crashing
the pipeline.

Discovered via autoresearch: 旧城暗号 failed at ch16 with
"unknown hook: H012".
Ma 7 ヶ月 前
親
コミット
88a341a6da
1 ファイル変更、3 行追加、2 行削除
  1. 3 2
      packages/core/src/state/state-reducer.ts

+ 3 - 2
packages/core/src/state/state-reducer.ts

@@ -105,7 +105,8 @@ function applyHookOps(hooksState: HooksState, delta: RuntimeStateDelta): HooksSt
   for (const hookId of delta.hookOps.resolve) {
   for (const hookId of delta.hookOps.resolve) {
     const existing = hooksById.get(hookId);
     const existing = hooksById.get(hookId);
     if (!existing) {
     if (!existing) {
-      throw new Error(`unknown hook: ${hookId}`);
+      // Hook may have been cleared by a previous settlement or not yet created — skip gracefully
+      continue;
     }
     }
     hooksById.set(hookId, {
     hooksById.set(hookId, {
       ...existing,
       ...existing,
@@ -117,7 +118,7 @@ function applyHookOps(hooksState: HooksState, delta: RuntimeStateDelta): HooksSt
   for (const hookId of delta.hookOps.defer) {
   for (const hookId of delta.hookOps.defer) {
     const existing = hooksById.get(hookId);
     const existing = hooksById.get(hookId);
     if (!existing) {
     if (!existing) {
-      throw new Error(`unknown hook: ${hookId}`);
+      continue;
     }
     }
     hooksById.set(hookId, {
     hooksById.set(hookId, {
       ...existing,
       ...existing,