File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
packages/react-devtools-shared/src/backend Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -229,9 +229,19 @@ export function patch({
229
229
// In Chromium, only the stack property is printed but in Firefox the <name>:<message>
230
230
// gets printed so to make the colon make sense, we name it so we print Stack:
231
231
// and similarly Safari leave an expandable slot.
232
- fakeError . name = enableOwnerStacks
233
- ? 'Stack'
234
- : 'Component Stack' ; // This gets printed
232
+ if ( __IS_CHROME__ || __IS_EDGE__ ) {
233
+ // Before sending the stack to Chrome DevTools for formatting,
234
+ // V8 will reconstruct this according to the template <name>: <message><stack-frames>
235
+ // https://source.chromium.org/chromium/chromium/src/+/main:v8/src/inspector/value-mirror.cc;l=252-311;drc=bdc48d1b1312cc40c00282efb1c9c5f41dcdca9a
236
+ // It has to start with ^[\w.]*Error\b to trigger stack formatting.
237
+ fakeError . name = enableOwnerStacks
238
+ ? 'Error Stack'
239
+ : 'Error Component Stack' ; // This gets printed
240
+ } else {
241
+ fakeError . name = enableOwnerStacks
242
+ ? 'Stack'
243
+ : 'Component Stack' ; // This gets printed
244
+ }
235
245
// In Chromium, the stack property needs to start with ^[\w.]*Error\b to trigger stack
236
246
// formatting. Otherwise it is left alone. So we prefix it. Otherwise we just override it
237
247
// to our own stack.
You can’t perform that action at this time.
0 commit comments