Bug/71901: Fix document connection error on Turbo navigation#21995
Open
Bug/71901: Fix document connection error on Turbo navigation#21995
Conversation
During Turbo page transitions, the old Stimulus controller's disconnect() fires after the new controller's connect(). The old controller unconditionally called LiveCollaborationManager.destroy(), which destroyed the new provider, closed the active WebSocket, and wiped all listeners. The React component then received a disconnect event and showed a spurious "connection error" banner. Fix with ownership-aware lifecycle management: - Add destroyIfOwner() to LiveCollaborationManager: uses reference equality so only the controller that created the active provider can destroy it. Make destroy() private to prevent bypassing the check. - Track ownedProvider in init-yjs-provider controller: disconnect() now calls destroyIfOwner() instead of unconditional destroy(). - Add offReady() to deregister listeners by reference. Both block-note-element and live-events controller now deregister their onReady callbacks on disconnect, preventing stale callbacks from firing into detached DOM elements. https://community.openproject.org/wp/71901
dfae953 to
3feae08
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
https://community.openproject.org/wp/71901
What are you trying to accomplish?
wp/71901/activity#comment-1630437
During Turbo page transitions, the old Stimulus controller's
disconnect()fires after the new controller'sconnect(). The old controller unconditionally calledLiveCollaborationManager.destroy(), which destroyed the new provider, closed the active WebSocket, and wiped all listeners. The React component then received a disconnect event and showed a spurious "connection error" banner.Screenshots
What approach did you choose and why?
Fix with ownership-aware lifecycle management:
LiveCollaborationManagerdoesn't destroy a provider it doesn't owndestroyIfOwner()offReady()to deregister listeners by reference. Both block-note-element and live-events controller now deregister theironReadycallbacks on disconnect, preventing stale callbacks from firing into detached DOM elements.Merge checklist