RTC: Fix disconnect dialog due to uneditable entity#77242
RTC: Fix disconnect dialog due to uneditable entity#77242alecgeatches merged 7 commits intotrunkfrom
Conversation
When the sync polling endpoint returns a 403, the affected room is now silently unregistered instead of showing a "connection lost" error and retrying. This treats the room as if sync was never supported for that entity. If the error message identifies a specific room, only that room is unregistered and polling continues for the rest. 401 errors continue to go through the normal retry/backoff path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ducing 403 requests
|
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: +205 B (0%) Total Size: 7.74 MB 📦 View Changed
ℹ️ View Unchanged
|
But should they be able to listen to changes and receive updates even though they don't have permission to send updates? |
@maxschmeling I think you're right about this. I created a follow-up issue #77277. This PR by itself still improves this case (read-only permissions cause full disconnect) but also other cases where we aren't allowed any access to a related entity. I think we can merge this as-is, and then improve the feature with #77277 and #77243. |
What?
Modify the HTTP polling sync provider to recognize per-entity 403s from the sync endpoint and unregister the affected rooms. Previously these 403s went through the normal retry/backoff path and eventually popped the "Connection lost" disconnect modal, even though only one entity in the session was actually unsyncable.
Here's a fast reproduction on
wp-env's default environment by using a user witheditorpermissions. Open a page as the editor, enable "Show Template", and see a disconnection dialog after a few seconds:disconnect-on-403.mp4
Why?
When an editor opens a Page that includes a
wp_template_part(like by toggling "Show template" in the sidebar), the page loads fine but the sync polling provider tries to register the template part for sync. The editor role doesn't haveedit_theme_options, so the server returns a 403 for that specific room. The provider treated this the same as a network error, eventually ending in the disconnect modal even though the user does not need the ability to edit the template.The correct behavior is to treat permission denials as per-entity for entities that can be skipped.
How?
The provider's error block now checks the error before treating the request as a failure and retrying. We substring match on the error returned by WordPress. An ideal future solution would be to return this data from the
WP_HTTP_Polling_Sync_Server(maybe asunauthorizedRooms: [...]). For now, this allows us to address the issue client-side and we can later improve onWP_HTTP_Polling_Sync_Serverby returning all affected entities. This issue will track that future work.This also fixes an issue where we were sending awareness disconnects for failed entities, resulting in two
403s instead of one. The fix was to add asendDisconnectSignalparameter tounregisterRoom(), and ensure that failed auth doesn't send the awareness disconnect signal.Testing Instructions
This is a bit tricky as mentioned above because
WP_HTTP_Polling_Sync_Serverships with WordPress and we can't easily override it in Gutenberg. The tests below usewp-envand manually patch the sync server that ships with WordPress./updatesbriefly respond with403, then after rooms are removed return to200responses.Unit tests can be run via:
npm run test:unit -- --testPathPattern='packages/sync/src/providers/http-polling/test/polling-manager'Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Used for: The whole process.