Closed Bug 1801462 Opened 2 years ago Closed 2 years ago

[Browser Console] Panel Crashed with 'TypeError: can't access property "level", message is undefined'

Categories

(DevTools :: Console, defect)

defect

Tracking

(firefox110 fixed)

RESOLVED FIXED
110 Branch
Tracking Status
firefox110 --- fixed

People

(Reporter: jdescottes, Assigned: nchevobbe)

References

Details

Attachments

(1 file)

I had a crash of the Browser Console, but I didn't see the crash immediately. I forgot the Browser Console was in the background, only saw the issue a few hours later.

Afterwards, I opened the Browser Toolbox to see if there were any messages around the time of the crash which could help identify the source, but there are no messages really close to the crash. The logs before and after both relate to chat.mozilla.org (so matrix), but they are minutes away from the crash, so it's not a strong indication.

getWarningGroupType@resource://devtools/client/webconsole/utils/messages.js:713:5
isMessageInWarningGroup@resource://devtools/client/webconsole/selectors/messages.js:70:8
renderMessage@resource://devtools/client/webconsole/components/Output/ConsoleOutput.js:302:15
render@resource://devtools/client/webconsole/components/Output/LazyMessageList.js:347:21
finishClassComponent@resource://devtools/client/shared/vendor/react-dom.js:10638:31
updateClassComponent@resource://devtools/client/shared/vendor/react-dom.js:10601:44
beginWork@resource://devtools/client/shared/vendor/react-dom.js:11419:16
performUnitOfWork@resource://devtools/client/shared/vendor/react-dom.js:14702:12
workLoop@resource://devtools/client/shared/vendor/react-dom.js:14720:24
renderRoot@resource://devtools/client/shared/vendor/react-dom.js:14803:15
performWorkOnRoot@resource://devtools/client/shared/vendor/react-dom.js:15655:17
performWork@resource://devtools/client/shared/vendor/react-dom.js:15567:24
performSyncWork@resource://devtools/client/shared/vendor/react-dom.js:15541:14
requestWork@resource://devtools/client/shared/vendor/react-dom.js:15410:5
scheduleWork@resource://devtools/client/shared/vendor/react-dom.js:15224:16
enqueueForceUpdate@resource://devtools/client/shared/vendor/react-dom.js:8225:17
Component.prototype.forceUpdate@resource://devtools/client/shared/vendor/react.js:346:16
#scrollHandler@resource://devtools/client/webconsole/components/Output/LazyMessageList.js:261:12

React Component Stack

componentStack
in LazyMessageList
in div
in ConsoleOutput
in VisibilityHandler
in Unknown
in Connect(Component)
in div
in div
in App
in VisibilityHandler
in Unknown
in Connect(Component)
in AppErrorBoundary
in LocalizationProvider
in Provider
in Provider
Flags: needinfo?(nchevobbe)

Here's what the stack suggests
In ConsoleOutput#renderMessage, we are using the passed message id to retrieve it and then calling isMessageInWarningGroup (only possible as there is at least one warning group)

https://searchfox.org/mozilla-central/rev/893a8f062ec6144c84403fbfb0a57234418b89cf/devtools/client/webconsole/components/Output/ConsoleOutput.js#286,300-306

const renderMessage = (messageId, index) => {
...
    inWarningGroup:
      warningGroups && warningGroups.size > 0
        ? isMessageInWarningGroup(
            mutableMessages.get(messageId),
            visibleMessages
          )
        : false,

isMessageInWarningGroup doesn't do much and only calls getWarningGroupType for the message

https://searchfox.org/mozilla-central/rev/893a8f062ec6144c84403fbfb0a57234418b89cf/devtools/client/webconsole/selectors/messages.js#69-70

function isMessageInWarningGroup(message, visibleMessages = []) {
  if (!getWarningGroupType(message)) {

then in getWarningGroupType there's an exception as we expect message to be an object

https://searchfox.org/mozilla-central/rev/893a8f062ec6144c84403fbfb0a57234418b89cf/devtools/client/webconsole/utils/messages.js#715-717

function getWarningGroupType(message) {
  if (
    message.level !== MESSAGE_LEVEL.WARN &&

but in this case message is undefined , and so this means that the earlier mutableMessages.get(messageId) returned undefined, meaning that messageId isn't in the Map.
At this point I can really tell why, we may have some race condition where the message is removed from the Map but we are still trying to render it, or it could be some mismatch between mutableMessages and mutableMessagesOrder

This should prevent to crash the browser until we find out
why this function is called with undefined.

Assignee: nobody → nchevobbe
Status: NEW → ASSIGNED
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/558916e4b3c5 [devtools] Guard getWarningGroupType on message. r=jdescottes.
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 110 Branch
Flags: needinfo?(nchevobbe)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: