fix: skip stale timeout responses (>2min old reject) to prevent phantom REJECT duplicates
This commit is contained in:
@@ -2055,6 +2055,18 @@ async function processResponseFile(filePath: string) {
|
||||
console.log(`Gravity Bridge: ${msg}`);
|
||||
logToFile(msg);
|
||||
|
||||
// Skip stale timeout responses: if pending is old and this is a reject, it's likely a bot timeout
|
||||
const ridTimestamp = parseInt((resp.request_id || '').split('_')[0], 10);
|
||||
if (!isNaN(ridTimestamp)) {
|
||||
const ageMs = Date.now() - ridTimestamp;
|
||||
const STALE_THRESHOLD_MS = 120_000; // 2 minutes
|
||||
if (ageMs > STALE_THRESHOLD_MS && !resp.approved) {
|
||||
logToFile(`[RESPONSE] SKIPPED stale timeout: rid=${resp.request_id} age=${Math.round(ageMs / 1000)}s (>${STALE_THRESHOLD_MS / 1000}s, reject)`);
|
||||
try { fs.unlinkSync(filePath); } catch { }
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Find matching pending request
|
||||
const pendingDir = path.join(bridgePath, 'pending');
|
||||
const pendingFile = path.join(pendingDir, `${resp.request_id}.json`);
|
||||
|
||||
Reference in New Issue
Block a user