Skip to content

Commit cb11155

Browse files
author
Brian Vaughn
authored
Add runtime type checks around module boundary code (#22748)
1 parent 56efc65 commit cb11155

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Diff for: packages/react-reconciler/src/SchedulingProfiler.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
import ReactVersion from 'shared/ReactVersion';
1919
import getComponentNameFromFiber from 'react-reconciler/src/getComponentNameFromFiber';
2020
import {SCHEDULING_PROFILER_VERSION} from 'react-devtools-timeline/src/constants';
21+
import isArray from 'shared/isArray';
2122

2223
import {
2324
getLabelForLane as getLabelForLane_old,
@@ -105,11 +106,18 @@ function markInternalModuleRanges() {
105106
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges === 'function'
106107
) {
107108
const ranges = __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges();
108-
for (let i = 0; i < ranges.length; i++) {
109-
const [startStackFrame, stopStackFrame] = ranges[i];
110-
111-
markAndClear(`--react-internal-module-start-${startStackFrame}`);
112-
markAndClear(`--react-internal-module-stop-${stopStackFrame}`);
109+
// This check would not be required,
110+
// except that it's possible for things to override __REACT_DEVTOOLS_GLOBAL_HOOK__.
111+
if (isArray(ranges)) {
112+
for (let i = 0; i < ranges.length; i++) {
113+
const range = ranges[i];
114+
if (isArray(range) && range.length === 2) {
115+
const [startStackFrame, stopStackFrame] = ranges[i];
116+
117+
markAndClear(`--react-internal-module-start-${startStackFrame}`);
118+
markAndClear(`--react-internal-module-stop-${stopStackFrame}`);
119+
}
120+
}
113121
}
114122
}
115123
}

0 commit comments

Comments
 (0)