Skip to content

fix(polling): no-operations sync response caused hot spin that ignored abort - #223

Open
nezumi0627 wants to merge 1 commit into
evex-dev:mainfrom
nezumi0627:fix/polling-busy-loop
Open

fix(polling): no-operations sync response caused hot spin that ignored abort#223
nezumi0627 wants to merge 1 commit into
evex-dev:mainfrom
nezumi0627:fix/polling-busy-loop

Conversation

@nezumi0627

Copy link
Copy Markdown
Contributor

Summary

Polling._listenTalkEvents (the deprecated but still exported polling generator) busy-looped whenever a sync response arrived without operationResponse.operations, which happens routinely (e.g. full-sync-only responses):

if (!(response.operationResponse && response.operationResponse.operations)) {
    continue; // skips sleep AND the AbortSignal check
}

The continue jumped back to while (true) without executing await sleep(pollingInterval) or if (signal?.aborted) break. Consequences:

  • talk.sync was hammered as fast as the event loop allowed (rate-limit / ban risk),
  • an AbortSignal could never stop the loop, because abort is only checked after the sleep.

Fix

Replace the early continue with a positive condition around the operations loop so every iteration falls through to the shared sleep/abort tail.

Testing

New mod.test.ts: stubs talk.sync to resolve {} (no operations), polls with a 50 ms interval, aborts after 150 ms. Asserts the poll count stays bounded and the loop actually terminates. On the old code this test never completes — the abort is ignored and syncCalls explodes.

Full suite: deno test --allow-all passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant