Repository: vercel/next.js
File: packages/next/src/server/lib/start-server.ts (TypeScript)

Code before:
      )
      process.exit(RESTART_EXIT_CODE)
    })
  }

  return { distDir }
}

if (process.env.NEXT_PRIVATE_WORKER && process.send) {
  process.addListener('message', async (msg: any) => {
    if (
      msg &&
      typeof msg === 'object' &&
      msg.nextWorkerOptions &&
      process.send
    ) {
      // Read experimental flags from environment if passed from parent process
      let experimentalFlagsFromParent = {}
      if (process.env.NEXT_PRIVATE_EXPERIMENTAL_FLAGS) {
        try {
          experimentalFlagsFromParent = JSON.parse(
            process.env.NEXT_PRIVATE_EXPERIMENTAL_FLAGS
          )
        } catch {
          console.error(
            'Failed to parse experimental flags from parent process'
          )
        }
      }

      startServerSpan = trace('start-dev-server', undefined, {
        cpus: String(os.cpus().length),
        platform: os.platform(),
        'memory.freeMem': String(os.freemem()),
        'memory.totalMem': String(os.totalmem()),
        'memory.heapSizeLimit': String(v8.getHeapStatistics().heap_size_limit),
        ...experimentalFlagsFromParent,
      })

      initializeTraceState({
        ...exportTraceState(),
        defaultParentSpanId: startServerSpan.getId(),
      })

      const result = await startServerSpan.traceAsyncFn(() =>
        startServer(msg.nextWorkerOptions)
      )
      const memoryUsage = process.memoryUsage()
      startServerSpan.setAttribute('memory.rss', String(memoryUsage.rss))
      startServerSpan.setAttribute(
        'memory.heapTotal',

Review comment (suggestion):
include the error object?

this should basically never happen so spammyness isn't too concerning

Code after:
      )
      process.exit(RESTART_EXIT_CODE)
    })
  }

  return { distDir }
}

if (process.env.NEXT_PRIVATE_WORKER && process.send) {
  process.addListener('message', async (msg: any) => {
    if (
      msg &&
      typeof msg === 'object' &&
      msg.nextWorkerOptions &&
      process.send
    ) {
      let enabledFeaturesFromParent = {}
      if (process.env.NEXT_PRIVATE_ENABLED_FEATURES) {
        const parsed = JSON.parse(process.env.NEXT_PRIVATE_ENABLED_FEATURES)
        enabledFeaturesFromParent = Object.fromEntries(
          Object.entries(parsed).map(([key, value]) => [
            `feature.${key}`,
            value,
          ])
        )
      }

      startServerSpan = trace('start-dev-server', undefined, {
        cpus: String(os.cpus().length),
        platform: os.platform(),
        'memory.freeMem': String(os.freemem()),
        'memory.totalMem': String(os.totalmem()),
        'memory.heapSizeLimit': String(v8.getHeapStatistics().heap_size_limit),
        ...enabledFeaturesFromParent,
      })

      initializeTraceState({
        ...exportTraceState(),
        defaultParentSpanId: startServerSpan.getId(),
      })

      const result = await startServerSpan.traceAsyncFn(() =>
        startServer(msg.nextWorkerOptions)
      )
      const memoryUsage = process.memoryUsage()
      startServerSpan.setAttribute('memory.rss', String(memoryUsage.rss))
      startServerSpan.setAttribute(
        'memory.heapTotal',
        String(memoryUsage.heapTotal)
      )
      startServerSpan.setAttribute(