MCPcopy Create free account
hub / github.com/vercel/vercel / _start

Method _start

packages/cli/src/util/dev/server.ts:1003–1268  ·  view source on GitHub ↗

* Launches the `vercel dev` server.

(...listenSpec: ListenSpec)

Source from the content-addressed store, hash-verified

1001 * Launches the `vercel dev` server.
1002 */
1003 async _start(...listenSpec: ListenSpec): Promise<void> {
1004 if (!fs.existsSync(this.cwd)) {
1005 throw new Error(`${chalk.bold(this.cwd)} doesn't exist`);
1006 }
1007
1008 if (!fs.lstatSync(this.cwd).isDirectory()) {
1009 throw new Error(`${chalk.bold(this.cwd)} is not a directory`);
1010 }
1011
1012 const { ig } = await getVercelIgnore(this.cwd);
1013 this.filter = ig.createFilter();
1014
1015 let address: string | null = null;
1016 while (typeof address !== 'string') {
1017 try {
1018 address = (await listen(this.server, ...listenSpec)).toString();
1019 } catch (err: unknown) {
1020 if (isErrnoException(err)) {
1021 output.debug(`Got listen error: ${err.code}`);
1022 if (err.code === 'EADDRINUSE') {
1023 if (typeof listenSpec[0] === 'number') {
1024 // Increase port and try again
1025 output.note(
1026 `Requested port ${chalk.yellow(
1027 String(listenSpec[0])
1028 )} is already in use`
1029 );
1030 listenSpec[0]++;
1031 } else {
1032 output.error(
1033 `Requested socket ${chalk.cyan(
1034 listenSpec[0]
1035 )} is already in use`
1036 );
1037 process.exit(1);
1038 }
1039 }
1040 } else {
1041 throw err;
1042 }
1043 }
1044 }
1045
1046 this._address = new URL(replaceLocalhost(address));
1047
1048 const vercelConfig = await this.getVercelConfig();
1049
1050 let devCommandPromise: Promise<void> | undefined;
1051 if (this.shouldUseServicesOrchestrator()) {
1052 this.orchestrator = new ServicesOrchestrator({
1053 services: this.services || [],
1054 cwd: this.cwd,
1055 repoRoot: this.repoRoot,
1056 env: this.envConfigs.allEnv,
1057 proxyOrigin: this.address.origin,
1058 useImplicitEnvInjection: this.useImplicitServicesEnvInjection,
1059 });
1060 devCommandPromise = this.orchestrator.startAll();

Callers 7

startMethod · 0.95
jquery.fancybox.jsFile · 0.80
jquery.fancybox.jsFile · 0.80
jquery.fancybox.jsFile · 0.80

Calls 15

getVercelConfigMethod · 0.95
runDevCommandMethod · 0.95
updateBuildMatchesMethod · 0.95
enqueueFsEventMethod · 0.95
getVercelIgnoreFunction · 0.90
isErrnoExceptionFunction · 0.90
replaceLocalhostFunction · 0.90
relativeFunction · 0.90
executeBuildFunction · 0.90
devRouterFunction · 0.90
linkFunction · 0.85

Tested by

no test coverage detected