瀏覽代碼

fix(scripts): terminate host process on all smoke paths

When the health check fails, stopProcess was never reached and the spawned opencode serve kept running as an orphan after the temp dir cleanup. Move the stop into a finally block; stopProcess already no-ops for exited children.
pxmps 1 周之前
父節點
當前提交
64940e40ff
共有 1 個文件被更改,包括 8 次插入5 次删除
  1. 8 5
      scripts/verify-opencode-host-smoke.ts

+ 8 - 5
scripts/verify-opencode-host-smoke.ts

@@ -293,17 +293,20 @@ async function verifyHostSmoke(tarballPath: string) {
         ),
         ),
         exitPromise,
         exitPromise,
       ]);
       ]);
+
+      await new Promise((resolve) => setTimeout(resolve, 1500));
+      assertNoPluginLoadErrors(`${stdout}\n${stderr}`);
     } catch (error) {
     } catch (error) {
       const message = error instanceof Error ? error.message : String(error);
       const message = error instanceof Error ? error.message : String(error);
       fail(
       fail(
         `${message}\nCaptured OpenCode logs:\n${formatCapturedLogs(stdout, stderr)}`,
         `${message}\nCaptured OpenCode logs:\n${formatCapturedLogs(stdout, stderr)}`,
       );
       );
+    } finally {
+      // Always terminate the spawned server, including on the health-check
+      // failure path where stopProcess would otherwise never be reached and
+      // the child process would leak away after the temp dir is removed.
+      await stopProcess(child);
     }
     }
-
-    await new Promise((resolve) => setTimeout(resolve, 1500));
-    assertNoPluginLoadErrors(`${stdout}\n${stderr}`);
-
-    await stopProcess(child);
   } finally {
   } finally {
     rmSync(tempRoot, { recursive: true, force: true });
     rmSync(tempRoot, { recursive: true, force: true });
   }
   }