{"record":{"id":"14de06a4bedd0870","repo":"vercel/next.js","slug":"server-is-approaching-the-used-memory-threshold-r","errorCode":null,"errorMessage":"Server is approaching the used memory threshold, restarting...","messagePattern":"Server is approaching the used memory threshold, restarting\\.\\.\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/lib/start-server.ts","lineNumber":260,"sourceCode":"    try {\n      if (handlersPromise) {\n        await handlersPromise\n        handlersPromise = undefined\n      }\n      await requestHandler(req, res)\n    } catch (err) {\n      res.statusCode = 500\n      res.end('Internal Server Error')\n      Log.error(`Failed to handle request for ${req.url}`)\n      console.error(err)\n    } finally {\n      const memoryRestartStats = getMemoryRestartStats(\n        isDev,\n        devMemoryThresholdRestart,\n        v8.getHeapStatistics\n      )\n      if (memoryRestartStats) {\n        Log.warn(\n          `Server is approaching the used memory threshold, restarting...`\n        )\n        trace('server-restart-close-to-memory-threshold', undefined, {\n          'memory.heapSizeLimit': String(memoryRestartStats.heap_size_limit),\n          'memory.heapUsed': String(memoryRestartStats.used_heap_size),\n        }).stop()\n        flushAllTraces()\n        process.exit(RESTART_EXIT_CODE)\n      }\n    }\n  }\n\n  const server = selfSignedCertificate\n    ? https.createServer(\n        {\n          key: fs.readFileSync(selfSignedCertificate.key),\n          cert: fs.readFileSync(selfSignedCertificate.cert),\n        },","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/vercel/next.js/blob/89d017eac43ebf4742ed2b58d3c1373b70283b69/packages/next/src/server/lib/start-server.ts#L242-L278","documentation":"Warning from the requestListener's finally block in start-server: after every request it calls getMemoryRestartStats with v8 heap statistics, and when used heap approaches the devMemoryThresholdRestart limit the dev server logs this and triggers a restart to reclaim memory before the process is OOM-killed. It is a self-healing measure, not a request failure.","triggerScenarios":"Thrown at packages/next/src/server/lib/start-server.ts:260 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce server memory usage or increase the memory limit / available memory to avoid restarts."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"89d017eac43ebf4742ed2b58d3c1373b70283b69","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}