mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-26 20:45:15 +02:00
fix: add safety timeout to session.compact() to prevent lane deadlock
When embedded compaction runs hang indefinitely (e.g., provider timeout without rejection), the session lane remains permanently stuck because the lane task never completes. Add a 5-minute safety timeout around session.compact() so the Promise always settles, allowing the lane to drain and process subsequent messages. Closes #16331 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Gustavo Madeira Santana
parent
542271e305
commit
b8825097c7
@@ -632,7 +632,17 @@ export async function compactEmbeddedPiSessionDirect(
|
||||
}
|
||||
|
||||
const compactStartedAt = Date.now();
|
||||
const result = await session.compact(params.customInstructions);
|
||||
const COMPACT_TIMEOUT_MS = 300_000; // 5 minutes safety timeout
|
||||
const result = await Promise.race([
|
||||
session.compact(params.customInstructions),
|
||||
new Promise<never>((_, reject) => {
|
||||
const timer = setTimeout(
|
||||
() => reject(new Error("Compaction timed out")),
|
||||
COMPACT_TIMEOUT_MS,
|
||||
);
|
||||
timer.unref?.();
|
||||
}),
|
||||
]);
|
||||
// Estimate tokens after compaction by summing token estimates for remaining messages
|
||||
let tokensAfter: number | undefined;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user