@samitouri / QOS-React-2 / commits / f2fd1b80d5

Updated the utfDecodeString() method to avoid call stack exceeded error (#22330)

Brian Vaughn committed Sep 17, 2021 at 09:52 UTC f2fd1b80d5501a0bce00641f383d18cbd24e3d32
1 file changed +10 -1
packages/react-devtools-shared/src/utils.js
+10 -1
@@ -126,7 +126,16 @@ export function getUID(): number {
126 }
127
128 export function utfDecodeString(array: Array<number>): string {
129 - return String.fromCodePoint(...array);
129 + // Avoid spreading the array (e.g. String.fromCodePoint(...array))
130 + // Functions arguments are first placed on the stack before the function is called
131 + // which throws a RangeError for large arrays.
132 + // See github.com/facebook/react/issues/22293
133 + let string = '';
134 + for (let i = 0; i < array.length; i++) {
135 + const char = array[i];
136 + string += String.fromCodePoint(char);
137 + }
138 + return string;
139 }
140
141 export function utfEncodeString(string: string): Array<number> {