Browse Source

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 week ago
parent
commit
64940e40ff
1 changed files with 8 additions and 5 deletions
  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,
       ]);
+
+      await new Promise((resolve) => setTimeout(resolve, 1500));
+      assertNoPluginLoadErrors(`${stdout}\n${stderr}`);
     } catch (error) {
       const message = error instanceof Error ? error.message : String(error);
       fail(
         `${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 {
     rmSync(tempRoot, { recursive: true, force: true });
   }