From d25141a765c29dc9a4e644192ee6fddd0a043249 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Fri, 14 Nov 2025 19:47:38 +0100 Subject: [PATCH] Fix: Stop polling when offer expires or connection succeeds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- src/connection.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/connection.ts b/src/connection.ts index bc1d0e8..43670d8 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -132,6 +132,8 @@ export class RondevuConnection { break; case 'connected': this.emit('connected'); + // Stop polling once connected - we have all the ICE candidates we need + this.stopPolling(); break; case 'disconnected': case 'failed': @@ -261,6 +263,10 @@ export class RondevuConnection { } } catch (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); } @@ -287,6 +293,10 @@ export class RondevuConnection { } } catch (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); }