-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Awaiting Maintainer ApprovalNeeds review from a maintainer before moving forwardNeeds review from a maintainer before moving forwardBugError or unexpected behaviorsError or unexpected behaviors
Description
p5.js version
No response
What is your operating system?
None
Web browser and version
No response
Actual Behavior
client/modules/IDE/components/Editor/index.jsx has been leaking event
listeners since forever. Line 1 even has a TODO to convert it to a
functional component, so this has been known but nobody fixed the leaks.
Problems:
- componentDidMount registers click, keydown, and change (debounced)
listeners on the CodeMirror instance. componentWillUnmount only removes
keyup. The rest are gone forever. click and keydown are anonymous arrow
functions so they can't even be removed with .off() as-is.
componentWillUnmount() {
if (this._cm) {
this._cm.off('keyup', this.handleKeyUp); // only this gets cleaned up
}
this.props.provideController(null);
}
-
componentWillUpdate (line ~260) is deprecated since React 16.3.
componentDidUpdate already exists, the logic should just move there. -
The debounced change handler is never cancelled on unmount, so it can
fire after the component is gone.
Fix:
- Convert anonymous listeners to named methods so they can be properly
unregistered - Cleanup all listeners in componentWillUnmount
- Move componentWillUpdate logic into componentDidUpdate
- Cancel debounced handler on unmount
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Awaiting Maintainer ApprovalNeeds review from a maintainer before moving forwardNeeds review from a maintainer before moving forwardBugError or unexpected behaviorsError or unexpected behaviors