Skip to content

Bug/71901: Fix document connection error on Turbo navigation#21995

Open
akabiru wants to merge 1 commit intodevfrom
bug/71901-connection-error-when-clicking-on-document-title-in-project-activity-log
Open

Bug/71901: Fix document connection error on Turbo navigation#21995
akabiru wants to merge 1 commit intodevfrom
bug/71901-connection-error-when-clicking-on-document-title-in-project-activity-log

Conversation

@akabiru
Copy link
Member

@akabiru akabiru commented Feb 13, 2026

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'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.

Screenshots

Screenshot 2026-02-13 at 12 29 50 PM

What approach did you choose and why?

Fix with ownership-aware lifecycle management:

  • ownership bug: ensure LiveCollaborationManager doesn't destroy a provider it doesn't own destroyIfOwner()
  • 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.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

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
@akabiru akabiru force-pushed the bug/71901-connection-error-when-clicking-on-document-title-in-project-activity-log branch from dfae953 to 3feae08 Compare February 13, 2026 17:43
@akabiru akabiru marked this pull request as ready for review February 16, 2026 09:05
@akabiru akabiru requested a review from a team February 16, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant

Comments