Skip to content

Switch back to using sigterm so that processes can tear down cleanly #79

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/utils/execUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ function killTree(childProcess: cp.ChildProcessWithoutNullStreams): Promise<void

console.log(`Killing process ${childProcessPid} and its descendents: ${strictDescendentPids.join(", ")}`);

strictDescendentPids.forEach(pid => process.kill(pid, "SIGKILL"));
childProcess.kill("SIGKILL");
strictDescendentPids.forEach(pid => process.kill(pid));
childProcess.kill();
// Resolve when we detect that childProcess has closed (above)
});
});
Expand Down
9 changes: 9 additions & 0 deletions src/utils/exerciseServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ async function exerciseServerWorker(testDir: string, tsserverPath: string, repla
"--expose-gc",
]);

// You can only wait for kill if the process being killed is the current process's
// child, so it's helpful to our caller if we tear down the server.
process.once("SIGTERM", async () => {
exitExpected = true; // Shouldn't matter, but might as well
await server.kill();
// This is a sneaky way to invoke node's default SIGTERM handler
process.kill(process.pid, "SIGTERM");
});

let loadedNewProject = false;
server.on("event", async (e: any) => {
switch (e.event) {
Expand Down