vercel/next.js · error

Long running GC detected: ${entry.duration.toFixed(2)}ms

Error message

Long running GC detected: ${entry.duration.toFixed(2)}ms

What it means

The gc-observer PerformanceObserver records every GC event and warns when a garbage-collection pause exceeds LONG_RUNNING_GC_THRESHOLD_MS (15ms), since long pauses signal memory pressure hurting dev/build performance; observation continues afterwards.

Source

Thrown at packages/next/src/lib/memory/gc-observer.ts:13

import { PerformanceObserver } from 'perf_hooks'
import { warn } from '../../build/output/log'
import { bold } from '../picocolors'

const LONG_RUNNING_GC_THRESHOLD_MS = 15

const gcEvents: PerformanceEntry[] = []
const obs = new PerformanceObserver((list) => {
  const entry = list.getEntries()[0]
  gcEvents.push(entry)

  if (entry.duration > LONG_RUNNING_GC_THRESHOLD_MS) {
    warn(bold(`Long running GC detected: ${entry.duration.toFixed(2)}ms`))
  }
})

/**
 * Starts recording garbage collection events in the process and warn on long
 * running GCs. To disable, call `stopObservingGc`.
 */
export function startObservingGc() {
  obs.observe({ entryTypes: ['gc'] })
}

export function stopObservingGc() {
  obs.disconnect()
}

/**
 * Returns all recorded garbage collection events. This function will only
 * return information from when `startObservingGc` was enabled and before

View on GitHub (pinned to 0eb3775416)

Solutions

  1. Investigate memory pressure in the Node process; consider increasing heap size (--max-old-space-size) or reducing retained objects.
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at packages/next/src/lib/memory/gc-observer.ts:13 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of vercel/next.js@0eb3775416 (2026-08-19). Data as JSON: /api/errors/e8f9f7b94cc30ca1. Report an issue: GitHub.