mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-07 04:22:04 +00:00
[cli][next] Removed --forceExit from jest args (#8718)
Remove `--forceExit` and wait for the child `vc dev` process to close before continuing. Listen to the `'close'` event instead of `'exit'` to ensure stdio has been flushed and closed before continuing. Some tests cause `vc dev` to spawn child processes that in turn spawn nested child processes that do not exit when the parent exits, so a `nukeProcessTree()` helper was added to ensure all spawned processes are cleaned up. Furthermore, some of the nested child processes don't respond well to `SIGTERM` and we need to use `SIGKILL` if `SIGTERM` doesn't do the job. I uncovered a larger issue exposed by removing the `--forceExit` flag. The go builder uses `go run` to build and run the go-based serverless function. Turns out that `go run` will build the executable, then spawn it with a parent process id (ppid) of `1` (launchd) on macOS. This means that the go serverless function executable is not detected as a child process of `vc dev` and won't be cleaned up, yet has inherited `stdout` and `stderr` keeping Jest alive. The solution is to explicitly `go build` the serverless executable, then run it. ### 📋 Checklist <!-- Please keep your PR as a Draft until the checklist is complete --> #### Tests - [x] The code changed/added as part of this PR has been covered with tests - [x] All tests pass locally with `yarn test-unit` #### Code Review - [ ] This PR has a concise title and thorough description useful to a reviewer - [ ] Issue from task tracker has a link to this PR Co-authored-by: Sean Massa <EndangeredMassa@gmail.com>
This commit is contained in:
@@ -1026,7 +1026,7 @@ export default class DevServer {
|
||||
debug(`Killing builder dev server with PID ${pid}`);
|
||||
this.devServerPids.delete(pid);
|
||||
try {
|
||||
process.kill(pid, 'SIGTERM');
|
||||
await treeKill(pid);
|
||||
debug(`Killed builder dev server with PID ${pid}`);
|
||||
} catch (err) {
|
||||
debug(`Failed to kill builder dev server with PID ${pid}: ${err}`);
|
||||
@@ -2279,6 +2279,10 @@ export default class DevServer {
|
||||
|
||||
p.on('exit', (code, signal) => {
|
||||
this.output.debug(`Dev command exited with "${signal || code}"`);
|
||||
});
|
||||
|
||||
p.on('close', (code, signal) => {
|
||||
this.output.debug(`Dev command closed with "${signal || code}"`);
|
||||
this.devProcessOrigin = undefined;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user