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

Function startDevServer

packages/container/src/dev.ts:438–466  ·  view source on GitHub ↗
(
  options: StartDevServerOptions
)

Source from the content-addressed store, hash-verified

436 * the app can honor, and returns the host port for the dev proxy to target.
437 */
438export async function startDevServer(
439 options: StartDevServerOptions
440): Promise<StartDevServerResult> {
441 // Reuse a live container for this service instead of rebuilding/running on
442 // every request. The dev server calls `startDevServer` per request; a
443 // container is a persistent server, so we hand back the running one.
444 const reuseKey = containerReuseKey(options);
445 const existing = runningContainers.get(reuseKey);
446 if (existing && existing.isRunning()) {
447 return existing.result;
448 }
449 if (existing) {
450 // Stale (exited) entry — clear it before starting a replacement.
451 runningContainers.delete(reuseKey);
452 }
453
454 // Coalesce concurrent cold starts: if a start for this service is already in
455 // flight, wait on it rather than spawning a second container.
456 const inFlight = pendingContainers.get(reuseKey);
457 if (inFlight) {
458 return inFlight;
459 }
460
461 const startPromise = startContainer(options, reuseKey).finally(() => {
462 pendingContainers.delete(reuseKey);
463 });
464 pendingContainers.set(reuseKey, startPromise);
465 return startPromise;
466}
467
468async function startContainer(
469 options: StartDevServerOptions,

Callers 1

unit.test.tsFile · 0.90

Calls 5

containerReuseKeyFunction · 0.85
startContainerFunction · 0.85
getMethod · 0.65
deleteMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected