[lexical-react] Bug Fix: CollaborationPlugin recreates the provider when providerFactory changes - #8965
Closed
LeSingh1 wants to merge 1 commit into
Closed
Conversation
…hen providerFactory changes CollaborationPlugin guarded provider creation with an `isProviderInitialized` ref that was never reset, so the provider was created exactly once for the lifetime of the component. Changing `providerFactory` (or `id`) afterwards had no effect, which makes it impossible to reconnect with refreshed connection parameters such as a rotated auth token. Replace the boolean guard with a ref that remembers the inputs the current provider was built from. The effect stays idempotent for StrictMode/remount re-runs with unchanged inputs, but a genuine change now tears down the old provider and creates a new one.
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 8, 2026 00:06
|
@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
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.
CollaborationPluginguards provider creation with anisProviderInitializedref that is set on first run and never reset, so the effect's[id, providerFactory, yjsDocMap]dependencies never take effect — the provider is created exactly once for the lifetime of the component. ChangingproviderFactoryafterwards does nothing, which makes it impossible to reconnect with refreshed connection parameters such as a rotated auth token.The guard exists so that a StrictMode/remount re-run with unchanged inputs does not create a second provider. This replaces it with a ref that remembers the inputs the current provider was built from, and short-circuits only when all of them are identical. The effect stays idempotent for re-runs, but a genuine change now tears down the old provider and creates a new one.
The binding is intentionally left alone: it is keyed to the Yjs document, which the documented
getDocFromMapfactory pattern preserves across a provider re-create.Adds a unit test that re-renders with a new factory and asserts the new provider is created and connected and the old one disconnected; it fails on
main.Fixes #7136