mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-10 19:03:24 +00:00
Fix: Stop polling when offer expires or connection succeeds
- Stop polling when 404 error (offer not found/expired) - Stop polling once connection state is 'connected' - Prevents unnecessary API calls and console errors - Improves resource cleanup 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -132,6 +132,8 @@ export class RondevuConnection {
|
|||||||
break;
|
break;
|
||||||
case 'connected':
|
case 'connected':
|
||||||
this.emit('connected');
|
this.emit('connected');
|
||||||
|
// Stop polling once connected - we have all the ICE candidates we need
|
||||||
|
this.stopPolling();
|
||||||
break;
|
break;
|
||||||
case 'disconnected':
|
case 'disconnected':
|
||||||
case 'failed':
|
case 'failed':
|
||||||
@@ -261,6 +263,10 @@ export class RondevuConnection {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error polling for answers:', err);
|
console.error('Error polling for answers:', err);
|
||||||
|
// Stop polling if offer expired/not found
|
||||||
|
if (err instanceof Error && err.message.includes('not found')) {
|
||||||
|
this.stopPolling();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 2000);
|
}, 2000);
|
||||||
}
|
}
|
||||||
@@ -287,6 +293,10 @@ export class RondevuConnection {
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error polling for ICE candidates:', err);
|
console.error('Error polling for ICE candidates:', err);
|
||||||
|
// Stop polling if offer expired/not found
|
||||||
|
if (err instanceof Error && err.message.includes('not found')) {
|
||||||
|
this.stopPolling();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user