{"record":{"id":"7f2a719356732293","repo":"musistudio/claude-code-router","slug":"request-log-command-kind-raw-trace-update","errorCode":null,"errorMessage":"[request-log] ${command.kind === \"raw-trace-update\" ? \"Retaining\" : \"Dropping\"} ${command.kind} sequence ${command.sequence} after ${command.writeAttempts} failed write attempts: ${message.error || \"request log batch failed\"}","messagePattern":"\\[request-log\\] (.+?) (.+?) sequence (.+?) after (.+?) failed write attempts: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/core/src/observability/request-log-runtime.ts","lineNumber":785,"sourceCode":"      this.schedulePump(true);\n      return;\n    }\n\n    const command = batch.commands[0];\n    if (command.writeAttempts < maxCommandWriteAttempts) {\n      this.queue.unshift({ ...command, isolated: true });\n    } else {\n      this.outstandingBytes = Math.max(0, this.outstandingBytes - command.sizeBytes);\n      this.dropped += 1;\n      if (command.kind === \"record\") {\n        this.rememberRecordAdmission(command.input.requestId, {\n          accepted: false,\n          degraded: false,\n          reason: \"writer_unavailable\"\n        }, 0, resolveRecordBodyCapturePolicy(command.input));\n        this.scheduleRawTraceCleanup([command]);\n      }\n      console.warn(\n        `[request-log] ${command.kind === \"raw-trace-update\" ? \"Retaining\" : \"Dropping\"} ` +\n        `${command.kind} sequence ${command.sequence} after ` +\n        `${command.writeAttempts} failed write attempts: ${message.error || \"request log batch failed\"}`\n      );\n    }\n    this.schedulePump(true);\n  }\n\n  private handleWriterFailure(worker: Worker | undefined, error: Error): void {\n    if (!worker || worker !== this.writerWorker) return;\n    this.writerWorker = undefined;\n    this.writerWorkerReady = undefined;\n    void worker.terminate().catch(() => undefined);\n    for (const [, batch] of [...this.inFlight].reverse()) this.queue.unshift(...batch.commands);\n    this.inFlight.clear();\n    rejectPending(this.writerRequests, error);\n    if (this.closed) return;\n    this.writerRestartCount += 1;","sourceCodeStart":767,"sourceCodeEnd":803,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/observability/request-log-runtime.ts#L767-L803","documentation":"A request-log write command failed repeatedly (tracked by writeAttempts). Once attempts exceed a threshold, raw-trace-update commands are retained (retried later) while other command kinds are dropped, and this warning names the exact command kind, sequence number, attempt count, and underlying error. Log data is being lost or delayed.","triggerScenarios":"Persistent writer failures: disk full, DB locked by another process, permission errors on the log file, or a corrupted log store; each pump retry increments writeAttempts until the retention/drop decision fires.","commonSituations":"Log directory on a full volume; SQLite log DB locked by a backup job; readonly filesystem in a container; crash-looping writer.","solutions":["Free disk space or fix permissions on the log storage path","Check message.error for the root cause (SQLITE_BUSY, EACCES, ENOSPC) and address it","If a lock conflict, stop competing processes accessing the log store or enable WAL","Restart the service after fixing storage — dropped non-trace commands cannot be recovered"],"exampleFix":"# before: log store on full disk\nLOG_DB_PATH=/mnt/full-disk/logs.db\n\n# after\nLOG_DB_PATH=/var/lib/gateway/logs.db  # ensure >=10% free space","handlingStrategy":"retry","validationCode":"const stat = await fs.promises.stat(logDir);\nif (stat && (await fs.promises.statfs(logDir)).bsize * (await fs.promises.statfs(logDir)).bavail < 100 * 1024 * 1024) {\n  throw new Error(\"<100MB free for request logs\");\n}","typeGuard":null,"tryCatchPattern":"try { await writer.write(commands); } catch (e) { await persistToDeadLetter(commands, e); /* never drop silently */ }","preventionTips":["Disk space alerts on the log volume","Avoid concurrent processes locking the log store","Drain and verify writer health before high-traffic windows"],"tags":["request-log","write-failure","data-loss","storage"],"backgroundTag":"log-write-failed","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}