RTC: Prevent duplicate poll cycles#76059
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Size Change: -9 B (0%) Total Size: 6.87 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in cf7a709. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22599375955
|
* Prevent duplicate poll cycles * Fix type issue in test Co-authored-by: chriszarate <czarate@git.wordpress.org> Co-authored-by: maxschmeling <maxschmeling@git.wordpress.org>
* Prevent duplicate poll cycles * Fix type issue in test Co-authored-by: chriszarate <czarate@git.wordpress.org> Co-authored-by: maxschmeling <maxschmeling@git.wordpress.org>
|
I just cherry-picked this PR to the wp/7.0 branch to get it included in the next release: e767b95 |
* Prevent duplicate poll cycles * Fix type issue in test Co-authored-by: chriszarate <czarate@git.wordpress.org> Co-authored-by: maxschmeling <maxschmeling@git.wordpress.org>
What?
Fix a race condition in the RTC polling manager that causes multiple concurrent poll cycles.
Why?
PR #75843 introduced
handleVisibilityChangeto back off polling when the browser tab is inactive. When the tab becomes visible again, it callspoll()immediately so collaborator updates appear without delay. However, this can spawn a duplicate poll cycle when an HTTP request is already in-flight, leading to multiple concurrent poll chains that multiply over time.How?
The root cause is that
handleVisibilityChangecheckedisPollingbefore calling poll(), butisPollingis a "has polling ever started" flag. It’struefor the entire lifetime of the polling loop, not just while a request is in-flight. So the guard didn’t prevent callingpoll()during an activepostSyncUpdaterequest.Testing Instructions