Closed Bug 1441113 Opened 7 years ago Closed 7 years ago

Can only update a mounted or mounting component when closing Memory Tool

Categories

(DevTools :: Memory, defect, P2)

defect

Tracking

(firefox60 fixed)

RESOLVED FIXED
Firefox 60
Tracking Status
firefox60 --- fixed

People

(Reporter: miker, Assigned: miker)

Details

Attachments

(1 file)

STR:

1. Open Browser Console.
1. Open Memory Tool.
2. Close the DevTools Toolbox.

What happens:
"The following will be displayed in the browser console:
Warning: Can only update a mounted or mounting component. This usually means you called setState, replaceState, or forceUpdate on an unmounted component. This is a no-op.

Please check the code for the ToolboxController component."

Why does this happen?
Because the toolbox is closing the focus changes to the toolbox buttons and triggers this error.

There are two solutions:

1. Remove button focus listeners on toolbox teardown.
2. Use a mounted flag inside `devtools/client/framework/components/toolbox-controller.js`.
In the end I chose option 3: Avoid the code smell and work out why we are trying to access a component when it is no longer mounted.

The onclick handler of the toolbox close button looked like this... spot the deliberate mistake:

```
onClick: () => {
  closeToolbox();
  focusButton(closeButtonId);
},
```

So we were closing the toolbox and then trying to focus the toolbox's close button.

There is also an obvious race condition with setState inside the toolbox controller not using a callback even though the next line calls a function that uses this.state, which could cause intermittent issues.
Comment on attachment 8953967 [details]
Bug 1441113 - Can only update a mounted or mounting component when closing Memory Tool

https://reviewboard.mozilla.org/r/223120/#review229050

Looks good, thanks Mike
Attachment #8953967 - Flags: review?(nchevobbe) → review+
Has Regression Range: --- → no
Has STR: --- → yes
Pushed by mratcliffe@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c527412fc7de
Can only update a mounted or mounting component when closing Memory Tool r=nchevobbe
https://hg.mozilla.org/mozilla-central/rev/c527412fc7de
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 60
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: