mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 12:57:46 +00:00
[cli] Fix "now-dev-next" and "now-dev-static-build-routing" unit tests (#7824)
These two tests have been problematic on MacOS for a long time, but now that we've re-introduced `@vercel/next` into this repo, they've started to fail on Linux/Windows as well. So the idea is to use the `devCommand` property so that `@vercel/next` Builder doesn't get invoked at all. Since the `devCommand` property was not yet being unit tested, some logic in `vc build` needed to be adjusted in order to properly shut down the dev command (via `tree-kill` module) when the process was being stopped in order to cleanly shut down.
This commit is contained in:
@@ -89,6 +89,7 @@ import {
|
||||
} from './types';
|
||||
import { ProjectEnvVariable, ProjectSettings } from '../../types';
|
||||
import exposeSystemEnvs from './expose-system-envs';
|
||||
import { treeKill } from '../tree-kill';
|
||||
|
||||
const frontendRuntimeSet = new Set(
|
||||
frameworkList.map(f => f.useRuntime?.use || '@vercel/static-build')
|
||||
@@ -998,20 +999,7 @@ export default class DevServer {
|
||||
}
|
||||
|
||||
if (devProcess) {
|
||||
ops.push(
|
||||
new Promise<void>((resolve, reject) => {
|
||||
devProcess.once('exit', () => resolve());
|
||||
try {
|
||||
process.kill(devProcess.pid);
|
||||
} catch (err) {
|
||||
if (err.code === 'ESRCH') {
|
||||
// Process already exited
|
||||
return resolve();
|
||||
}
|
||||
reject(err);
|
||||
}
|
||||
})
|
||||
);
|
||||
ops.push(treeKill(devProcess.pid));
|
||||
}
|
||||
|
||||
ops.push(close(this.server));
|
||||
@@ -1052,12 +1040,7 @@ export default class DevServer {
|
||||
const { debug } = this.output;
|
||||
debug(`Killing builder dev server with PID ${pid}`);
|
||||
this.devServerPids.delete(pid);
|
||||
try {
|
||||
process.kill(pid, 'SIGTERM');
|
||||
debug(`Killed builder dev server with PID ${pid}`);
|
||||
} catch (err) {
|
||||
debug(`Failed to kill builder dev server with PID ${pid}: ${err}`);
|
||||
}
|
||||
await treeKill(pid);
|
||||
}
|
||||
|
||||
async send404(
|
||||
@@ -2120,7 +2103,7 @@ export default class DevServer {
|
||||
.replace(/%PORT%/g, `${port}`);
|
||||
|
||||
this.output.debug(
|
||||
`Starting dev command with parameters : ${JSON.stringify({
|
||||
`Starting dev command with parameters: ${JSON.stringify({
|
||||
cwd,
|
||||
command,
|
||||
port,
|
||||
@@ -2152,6 +2135,7 @@ export default class DevServer {
|
||||
cwd,
|
||||
env,
|
||||
});
|
||||
this.devProcess = p;
|
||||
|
||||
if (!p.stdout || !p.stderr) {
|
||||
throw new Error('Expected child process to have stdout and stderr');
|
||||
@@ -2164,17 +2148,14 @@ export default class DevServer {
|
||||
process.stdout.write(data.replace(proxyPort, devPort));
|
||||
});
|
||||
|
||||
p.on('exit', (code: number) => {
|
||||
if (code > 0) {
|
||||
process.exit(code);
|
||||
}
|
||||
p.on('exit', (code, signal) => {
|
||||
this.output.debug(`Dev command exited with "${signal || code}"`);
|
||||
this.devProcessPort = undefined;
|
||||
});
|
||||
|
||||
await checkForPort(port, 1000 * 60 * 5);
|
||||
|
||||
this.devProcessPort = port;
|
||||
this.devProcess = p;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user