feat(streaming): Improve task status polling and socket recovery

This commit is contained in:
cogwheel0
2025-12-01 11:52:04 +05:30
parent a245c4248f
commit 8005cbf6e0
2 changed files with 26 additions and 9 deletions

View File

@@ -204,12 +204,13 @@ ActiveSocketStream attachUnifiedChunkedStreaming({
final hasSocketSignals =
socketService != null || registerDeltaListener != null;
if (hasSocketSignals) {
// Use a reasonable inactivity timeout - if no data arrives for 45 seconds,
// something is likely wrong with the connection
// Use a short inactivity timeout - if no data arrives for 10 seconds,
// something is likely wrong with the connection. Combined with 1-second
// polling and server state sync, this provides fast recovery.
socketWatchdog = InactivityWatchdog(
window: const Duration(seconds: 45),
window: const Duration(seconds: 10),
// Absolute cap ensures streaming never gets stuck indefinitely
absoluteCap: const Duration(minutes: 10),
absoluteCap: const Duration(minutes: 5),
onTimeout: () {
DebugLogger.log(
'Socket watchdog timeout - finishing streaming gracefully',