Stabilize WeakMap in NodeEventPlugin #3780
Merged
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.
Today, while using the supremely useful
NodeEventPlugin
, I watched as the number of "click" event listeners on my code lines exponentially increased on every click.After some hunting and pecking, I discovered that the WeakMap that tracks elements in this plugin was being reset on every render. In other words, it reset to {} on each click. I therefore moved the WeakMap up a line, placing it outside the scope of the
registerMutationListener
function that makes use of it.Hark! The exponential increase ceased, the WeakMap stabilized, and a whole bunch of my code went from "bad" to "good."
@trueadm I see you worked heavily on this plugin, is this OK?
I have run
npm run test-unit
and observed Greenland. I am rolling the dice on the e2es, as I'm still not confident in them.This LinedCodeNode-related pull request is sibling to:
#3770
#3769
#3695
#3731
#3695
#3693