fix: skip stale timeout responses (>2min old reject) to prevent phantom REJECT duplicates
This commit is contained in:
@@ -2100,6 +2100,20 @@ async function processResponseFile(filePath) {
|
|||||||
const msg = `[RESPONSE] rid=${resp.request_id} approved=${resp.approved} step_type=${resp.step_type || '(missing)'} keys=[${Object.keys(resp).join(',')}]`;
|
const msg = `[RESPONSE] rid=${resp.request_id} approved=${resp.approved} step_type=${resp.step_type || '(missing)'} keys=[${Object.keys(resp).join(',')}]`;
|
||||||
console.log(`Gravity Bridge: ${msg}`);
|
console.log(`Gravity Bridge: ${msg}`);
|
||||||
logToFile(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
|
// Find matching pending request
|
||||||
const pendingDir = path.join(bridgePath, 'pending');
|
const pendingDir = path.join(bridgePath, 'pending');
|
||||||
const pendingFile = path.join(pendingDir, `${resp.request_id}.json`);
|
const pendingFile = path.join(pendingDir, `${resp.request_id}.json`);
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -2055,6 +2055,18 @@ async function processResponseFile(filePath: string) {
|
|||||||
console.log(`Gravity Bridge: ${msg}`);
|
console.log(`Gravity Bridge: ${msg}`);
|
||||||
logToFile(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
|
// Find matching pending request
|
||||||
const pendingDir = path.join(bridgePath, 'pending');
|
const pendingDir = path.join(bridgePath, 'pending');
|
||||||
const pendingFile = path.join(pendingDir, `${resp.request_id}.json`);
|
const pendingFile = path.join(pendingDir, `${resp.request_id}.json`);
|
||||||
|
|||||||
Reference in New Issue
Block a user