History

Fix workerd dispose reaping and declare effect peer dependency

Rhys Sullivan committed 4 months ago

Commit 02cc5e11 parent 21afc264 files · +14 −3Browse files

Unified · Split

4 files
  1. bun.lock +3 −0
  2. packages/kernel/runtime-workerd-subprocess/src/index.test.ts +5 −2
  3. packages/kernel/runtime-workerd-subprocess/src/index.ts +3 −1
  4. packages/plugins/apps/package.json +3 −0
bun.lock+3−0
@@ -808,6 +808,9 @@ · 807 unmodified lines
808 "tsup": "catalog:",808 "tsup": "catalog:",
809 "vitest": "catalog:",809 "vitest": "catalog:",
810 },810 },
811 "peerDependencies": {
812 "effect": "catalog:",
813 },
811 },814 },
812 "packages/plugins/desktop-settings": {815 "packages/plugins/desktop-settings": {
813 "name": "@executor-js/plugin-desktop-settings",816 "name": "@executor-js/plugin-desktop-settings",
packages/kernel/runtime-workerd-subprocess/src/index.test.ts+5−2
@@ -93,9 +93,12 @@ const pidIsGone = (pid: number): boolean => { · 92 unmodified lines
93};93};
94 94
95const waitUntilGone = async (pid: number): Promise<boolean> => {95const waitUntilGone = async (pid: number): Promise<boolean> => {
96 for (let index = 0; index < 100; index += 1) {96 // kill(pid, 0) still succeeds for an exited-but-unreaped child, so poll on a
97 // real timer long enough for Node to reap it after the exit event.
98 const deadline = Date.now() + 5_000;
99 while (Date.now() < deadline) {
97 if (pidIsGone(pid)) return true;100 if (pidIsGone(pid)) return true;
98 await new Promise((resolve) => setImmediate(resolve));101 await new Promise((resolve) => setTimeout(resolve, 10));
99 }102 }
100 return pidIsGone(pid);103 return pidIsGone(pid);
101};104};
packages/kernel/runtime-workerd-subprocess/src/index.ts+3−1
@@ -363,9 +363,11 @@ export const createWorkerdModuleRunner = ( · 362 unmodified lines
363 const state = processState;363 const state = processState;
364 processState = undefined;364 processState = undefined;
365 if (!state) return;365 if (!state) return;
366 if (kill && !state.proc.killed) {366 if (kill && state.proc.exitCode === null && state.proc.signalCode === null) {
367 // workerd serve ignores SIGTERM in this version. SIGKILL is the verified immediate shutdown path.367 // workerd serve ignores SIGTERM in this version. SIGKILL is the verified immediate shutdown path.
368 const exited = new Promise<void>((resolve) => state.proc.once("exit", () => resolve()));
368 state.proc.kill("SIGKILL");369 state.proc.kill("SIGKILL");
370 await exited;
369 }371 }
370 await closeServer(state.hostServer).catch(() => undefined);372 await closeServer(state.hostServer).catch(() => undefined);
371 await rm(state.tmp, { recursive: true, force: true }).catch(() => undefined);373 await rm(state.tmp, { recursive: true, force: true }).catch(() => undefined);
packages/plugins/apps/package.json+3−0
@@ -45,5 +45,8 @@ · 44 unmodified lines
45 "effect": "catalog:",45 "effect": "catalog:",
46 "tsup": "catalog:",46 "tsup": "catalog:",
47 "vitest": "catalog:"47 "vitest": "catalog:"
48 },
49 "peerDependencies": {
50 "effect": "catalog:"
48 }51 }
49}52}