refactor[react-devtools/extensions]: dont debounce cleanup logic on navigation #30027
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.
Summary
There is a race condition in the way we poll if React is on the page and when we actually clear this polling instance. When user navigates to a different page, we will debounce a callback for 500ms, which will:
Since the cleanup logic is debounced, there is a small chance that by the time we are going to clean up this polling instance, it will be
eval
-ed on the page, that is using React. For example, when user is navigating from the page which doesn't have React running, to a page that has React running.Next, we incorrectly will try to mount React DevTools panels twice, which will result into conflicts in the Store, and the error will be shown to the user
How did you test this change?
Since this is a race condition, it is hard to reproduce consistently, but you can try this flow:
"Looks like this page doesn't have React, or it hasn't been loaded yet"
message in RDT panel"Uncaught Error: Cannot add node "1" because a node with that id is already in the Store."
Couldn't been able to reproduce this with these changes.