4 Commits

Author SHA1 Message Date
275c156c64 0.18.3 2025-12-14 13:35:45 +01:00
c60a5f332a Merge remote-tracking branch 'origin/main' 2025-12-14 13:35:38 +01:00
Bas
ecd6be7f8a Merge pull request #7 from xtr-dev/claude/fix-issue-6-CTKj9
Fix issue #6
2025-12-14 13:35:19 +01:00
Claude
e652fdc130 Fix duplicate answer processing race condition (#6)
Add polling guard to prevent concurrent pollInternal() execution.
The setInterval callback doesn't await the async pollInternal(),
which could cause multiple polls to process the same answer before
lastPollTimestamp is updated, resulting in "Called in wrong state:
stable" errors from setRemoteDescription().
2025-12-14 11:59:43 +00:00
3 changed files with 14 additions and 3 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "@xtr-dev/rondevu-client",
"version": "0.18.2",
"version": "0.18.3",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@xtr-dev/rondevu-client",
"version": "0.18.2",
"version": "0.18.3",
"license": "MIT",
"dependencies": {
"@noble/ed25519": "^3.0.0"

View File

@@ -1,6 +1,6 @@
{
"name": "@xtr-dev/rondevu-client",
"version": "0.18.2",
"version": "0.18.3",
"description": "TypeScript client for Rondevu with durable WebRTC connections, automatic reconnection, and message queuing",
"type": "module",
"main": "dist/index.js",

View File

@@ -259,6 +259,7 @@ export class Rondevu extends EventEmitter {
private filling = false
private pollingInterval: ReturnType<typeof setInterval> | null = null
private lastPollTimestamp = 0
private isPolling = false // Guard against concurrent poll execution
private constructor(
apiUrl: string,
@@ -634,6 +635,13 @@ export class Rondevu extends EventEmitter {
private async pollInternal(): Promise<void> {
if (!this.filling) return
// Prevent concurrent poll execution to avoid duplicate answer processing
if (this.isPolling) {
this.debug('Poll already in progress, skipping')
return
}
this.isPolling = true
try {
const result = await this.api.poll(this.lastPollTimestamp)
@@ -674,6 +682,8 @@ export class Rondevu extends EventEmitter {
}
} catch (err) {
console.error('[Rondevu] Polling error:', err)
} finally {
this.isPolling = false
}
}
@@ -710,6 +720,7 @@ export class Rondevu extends EventEmitter {
stopFilling(): void {
this.debug('Stopping offer filling and polling')
this.filling = false
this.isPolling = false // Reset polling guard
// Stop polling
if (this.pollingInterval) {