Feed the list-view Share modals live metadata - #540
Maximo-Guk wants to merge 1 commit into
Conversation
Opening Share from the workspaces grid or the sidebar snapshotted getMetadata() once, so an ownerInvitesOnly update while the modal was open never reached it and the controls the server now refuses stayed visible. Both entry points subscribe for the modal's lifetime instead, as the editor already does. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
| const subscription = await overseer.subscribeToMetadata((metadata) => { | ||
| if (!opened) { | ||
| opened = true | ||
| setShareTarget({ ...gadget, ...metadata }) | ||
| return | ||
| } | ||
| // A functional update so a late delivery after close (prev === null) stays closed. | ||
| setShareTarget(prev => prev?.id === gadget.id ? { ...prev, ...metadata } : prev) | ||
| }) | ||
| setShareOverseer({ stub: overseer, subscription }) |
There was a problem hiding this comment.
🟡 Interrupted share opens leak RPC stubs
When the component unmounts during subscribeToMetadata, handleShare resolves after cleanup and leaves both stubs undisposed. The same race exists in onShare.
Learn more
The overseer is created before the subscription RPC begins, but both stubs enter shareOverseer only after that RPC resolves. The unmount cleanup reads shareOverseerRef, so it sees neither stub when navigation unmounts the list during the await. A later state update cannot install resources into an unmounted component, leaving the server-side capabilities alive. The established useWorkspaceOpen lifecycle keeps local stub references and disposes a subscription that resolves after cancellation.
Example: A user clicks Share and immediately navigates away while the subscription RPC is pending. Cleanup sees shareOverseerRef.current === null; when the RPC completes, its subscription and overseer have no remaining disposal path.
Recommended fix: Track cancellation for each share-open attempt and retain both stubs locally until ownership transfers to state. If the component unmounts before resolution, dispose the resolved subscription and overseer instead of calling the state setters. Apply the same lifecycle to onShare.
Was this helpful? React with 👍 or 👎 to provide feedback.
Preview:
|
|
No additional findings beyond the existing inline review comment. |
|
What's the motivator here? |
Oops sorry this should be drafted still! |
WIP
Follow-up to #523.