From f8fb8429351dcf3770eb3ae23525658d885fff00 Mon Sep 17 00:00:00 2001 From: Bas van den Aakster Date: Sun, 14 Dec 2025 14:39:15 +0100 Subject: [PATCH] Revert to v0.18.3 answer processing logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverted pollInternal to exactly match v0.18.3 which was the last working version. The changes in v0.18.5 and v0.18.6 that moved the answered flag and timestamp updates were causing issues. v0.18.3 working logic restored: - Check !activeOffer.answered - Call setRemoteDescription (no try/catch) - Set answered = true AFTER - Update lastPollTimestamp AFTER - No pre-emptive timestamp updates The only difference from v0.18.3 is the eventemitter3 import which should not affect answer processing behavior. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/rondevu.ts | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/src/rondevu.ts b/src/rondevu.ts index f101f5c..ba0b6b2 100644 --- a/src/rondevu.ts +++ b/src/rondevu.ts @@ -645,37 +645,23 @@ export class Rondevu extends EventEmitter { try { const result = await this.api.poll(this.lastPollTimestamp) - // Update timestamp FIRST to prevent re-fetching same answers if processing fails - if (result.answers.length > 0) { - const maxAnswerTimestamp = Math.max(...result.answers.map(a => a.answeredAt)) - this.lastPollTimestamp = Math.max(this.lastPollTimestamp, maxAnswerTimestamp) - } - // Process answers for (const answer of result.answers) { const activeOffer = this.activeOffers.get(answer.offerId) if (activeOffer && !activeOffer.answered) { this.debug(`Received answer for offer ${answer.offerId}`) - // Mark as answered BEFORE setRemoteDescription to prevent race condition + await activeOffer.pc.setRemoteDescription({ + type: 'answer', + sdp: answer.sdp + }) + activeOffer.answered = true + this.lastPollTimestamp = answer.answeredAt + this.emit('offer:answered', answer.offerId, answer.answererId) - try { - await activeOffer.pc.setRemoteDescription({ - type: 'answer', - sdp: answer.sdp - }) - - this.emit('offer:answered', answer.offerId, answer.answererId) - - // Create replacement offer - this.fillOffers() - } catch (err) { - // If setRemoteDescription fails, reset the answered flag - activeOffer.answered = false - this.debug(`Failed to set remote description for offer ${answer.offerId}:`, err) - // Don't throw - continue processing other answers - } + // Create replacement offer + this.fillOffers() } }