Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DevTools Bug]: TreeContext error: Can't access property "id" in undefined #24441

Closed
bvaughn opened this issue Apr 26, 2022 · 1 comment · Fixed by #24501
Closed

[DevTools Bug]: TreeContext error: Can't access property "id" in undefined #24441

bvaughn opened this issue Apr 26, 2022 · 1 comment · Fixed by #24501
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug

Comments

@bvaughn
Copy link
Contributor

bvaughn commented Apr 26, 2022

Website or app

https://app.replay.io/

Repro steps

Unfortunately I don't know how to reproduce this bug. It was just logged to Sentry.

It seems like there's a logic bug here though:

let flatIndex = 0;
if (selectedElementIndex !== null) {
// Resume from the current position in the list.
// Otherwise step to the previous item, relative to the current selection.
for (
let i = elementIndicesWithErrorsOrWarnings.length - 1;
i >= 0;
i--
) {
const {index} = elementIndicesWithErrorsOrWarnings[i];
if (index >= selectedElementIndex) {
flatIndex = i;
} else {
break;
}
}
}
let prevEntry;
if (flatIndex === 0) {
prevEntry =
elementIndicesWithErrorsOrWarnings[
elementIndicesWithErrorsOrWarnings.length - 1
];
selectedElementID = prevEntry.id;
selectedElementIndex = prevEntry.index;
} else {
prevEntry = elementIndicesWithErrorsOrWarnings[flatIndex - 1];
selectedElementID = prevEntry.id;
selectedElementIndex = prevEntry.index;
}

If selectedElementIndex is null or elementIndicesWithErrorsOrWarnings is empty, then flatIndex would be 0 still– and this statement would result in an undefined entry:

prevEntry =
  elementIndicesWithErrorsOrWarnings[
    elementIndicesWithErrorsOrWarnings.length - 1
  ];

How often does this bug happen?

Only once

DevTools package (automated)

react-devtools-inline

DevTools version (automated)

4.24.4

Error message (automated)

Error: can't access property "id", n is undefined

Error call stack (automated)

React ErrorBoundary Error: can't access property "id", n is undefined
  at TreeContextController(./node_modules/react-devtools-inline/dist/frontend.js:20793:10)
  at SettingsContextController(./node_modules/react-devtools-inline/dist/frontend.js:21419:10)
  at ModalDialogContextController(./node_modules/react-devtools-inline/dist/frontend.js:28526:10)
  at DevTools_DevTools(./node_modules/react-devtools-inline/dist/frontend.js:44535:10)
  at useMemo(./src/ui/components/SecondaryToolbox/ReactDevTools.tsx:269:1)
  at ConnectFunction(./node_modules/react-redux/es/components/connectAdvanced.js:220:22)
  at Redacted(./src/ui/components/Redacted.tsx:5:83)
  at SecondaryToolbox(./src/ui/components/SecondaryToolbox/index.tsx:119:25)
  at useGetShowVideo(./src/devtools/client/shared/components/splitter/SplitBox.tsx:25:37)

Error component stack (automated)

No response

GitHub query string (automated)

No response

@lunaruan
Copy link
Contributor

lunaruan commented May 4, 2022

Not sure if #24495 will fix your issue. Let me know if you can get a repro!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Developer Tools Status: Unconfirmed A potential issue that we haven't yet confirmed as a bug Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants