{"record":{"id":"0ac5772b9efaa7f3","repo":"abhigyanpatwari/GitNexus","slug":"worker-workerindex-exceeded-respawn-budget-dro","errorCode":null,"errorMessage":"Worker ${workerIndex} exceeded respawn budget; dropping slot.","messagePattern":"Worker (.+?) exceeded respawn budget; dropping slot\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"gitnexus/src/core/ingestion/workers/worker-pool.ts","lineNumber":1783,"sourceCode":"        if (stopped) return;\n        consecutiveFailuresPerSlot[workerIndex]++;\n        for (const p of excludePaths) {\n          if (p) quarantine.add(p);\n        }\n        if (consecutiveFailuresPerSlot[workerIndex] >= poolOptions.consecutiveFailureThreshold) {\n          tripBreaker(\n            new WorkerPoolDispatchError(\n              `${reason}. Pool circuit breaker tripped: slot ${workerIndex} hit ` +\n                `${consecutiveFailuresPerSlot[workerIndex]} consecutive failures ` +\n                `(threshold: ${poolOptions.consecutiveFailureThreshold}).`,\n              quarantine.snapshot(),\n            ),\n          );\n          return;\n        }\n        respawnCount[workerIndex]++;\n        if (respawnCount[workerIndex] > poolOptions.maxRespawnsPerSlot) {\n          logger.warn(\n            {\n              workerIndex,\n              respawnCount: respawnCount[workerIndex],\n              maxRespawns: poolOptions.maxRespawnsPerSlot,\n              reason,\n            },\n            `Worker ${workerIndex} exceeded respawn budget; dropping slot.`,\n          );\n          await removeWorkerFromSlot(workerIndex, removalMode, reason);\n          activeSlots.delete(workerIndex);\n          if (activeSlots.size === 0) {\n            tripBreaker(\n              new WorkerPoolDispatchError(\n                `${reason}. All ${size} worker slot(s) exhausted their respawn budget.`,\n                quarantine.snapshot(),\n              ),\n            );\n            return;","sourceCodeStart":1765,"sourceCodeEnd":1801,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/ingestion/workers/worker-pool.ts#L1765-L1801","documentation":"After a worker death, each slot counts respawns; when respawnCount exceeds maxRespawnsPerSlot (option, or GITNEXUS_WORKER_MAX_RESPAWNS_PER_SLOT), the slot is dropped: the worker is removed and the slot leaves activeSlots. If it was the last active slot, the pool trips the breaker with WorkerPoolDispatchError citing exhaustion; otherwise dispatch continues on the remaining slots.","triggerScenarios":"handleWorkerDeath incrementing respawnCount past the per-slot budget through repeated worker exits — native crashes, OOM deaths at the heap cap, or abort-prone files killing each replacement soon after spawn; the warn fires with workerIndex, respawnCount, maxRespawns, and reason.","commonSituations":"A repo containing several parser-crash files so every respawn dies again quickly; memory-constrained runners where each worker OOMs (heap cap) within minutes; or an ABI-broken native grammar crashing all workers deterministically.","solutions":["Read the reason field: heap-cap deaths say to raise GITNEXUS_WORKER_HEAP_MB; native/parse deaths point to a specific input or grammar","Fix the crash source (exclude the pathological file, fix the native install) — respawns treat symptoms, not causes","Raise GITNEXUS_WORKER_MAX_RESPAWNS_PER_SLOT only for genuinely transient environments, paired with lower parallelism","If dispatch later fails with 'All N worker slot(s) exhausted their respawn budget', treat that error's quarantine snapshot as the culprit list"],"exampleFix":"# before\nexport GITNEXUS_WORKER_POOL_SIZE=8   # repeated heap-cap deaths burn respawn budget → slot dropped\n# after\nexport GITNEXUS_WORKER_POOL_SIZE=4\nexport GITNEXUS_WORKER_HEAP_MB=1024  # fewer deaths, budget preserved","handlingStrategy":"validation","validationCode":"// Pre-flight respawn economics: transient-death-heavy environments need headroom.\nconst budget = Number(process.env.GITNEXUS_WORKER_MAX_RESPAWNS_PER_SLOT ?? 0);\nif (budget < expectedCrashesPerSlot) {\n  process.env.GITNEXUS_WORKER_MAX_RESPAWNS_PER_SLOT = String(expectedCrashesPerSlot);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fix crash sources (heap caps, native grammar ABI, poison files) before raising respawn budgets","Read the reason field on every respawn warn — heap-cap reasons point at memory, not luck","When the last slot drops, the WorkerPoolDispatchError carries the quarantine snapshot: use it for the post-mortem"],"tags":["worker-pool","respawn-budget","crash-recovery","slot-exhaustion"],"backgroundTag":"worker-crash-restart","analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}