Skip to content

Commit e99785f

Browse files
committed
Add unknown location information to component stacks (#30290)
This is the same change as in #30289 but for the main runtime - e.g. parent stacks in errorInfo.componentStack, appended stacks to console.error coming from React itself and when we add virtual frames to owner stacks. Since we don't add location information these frames look weird to some stack parsers - such as the native one. This is an existing issue when you want to use some off-the-shelf parsers to parse production component stacks for example. While we won't add Error objects to logs ourselves necessarily, some third party could want to do the same thing we do in DevTools and so we should provide the same capability to just take this trace and print it using an Error object. DiffTrain build for commit df783f9.
1 parent 9187f28 commit e99785f

16 files changed

+148
-64
lines changed

compiled-rn/VERSION_NATIVE_FB

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19.0.0-native-fb-58af67a8f8-20240628
1+
19.0.0-native-fb-df783f9ea1-20240708

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<7755eee04e60a5a5be47a6764dd66aef>>
10+
* @generated SignedSource<<b79bb3a4890e5e05b0b98d095f5ec6a9>>
1111
*/
1212

1313
"use strict";
@@ -357,8 +357,14 @@ __DEV__ &&
357357
} catch (x) {
358358
var match = x.stack.trim().match(/\n( *(at )?)/);
359359
prefix = (match && match[1]) || "";
360+
suffix =
361+
-1 < x.stack.indexOf("\n at")
362+
? " (<anonymous>)"
363+
: -1 < x.stack.indexOf("@")
364+
? "@unknown:0:0"
365+
: "";
360366
}
361-
return "\n" + prefix + name;
367+
return "\n" + prefix + name + suffix;
362368
}
363369
function describeNativeComponentFrame(fn, construct) {
364370
if (!fn || reentry) return "";
@@ -572,7 +578,7 @@ __DEV__ &&
572578
var JSCompiler_temp_const = info,
573579
env = entry.env;
574580
var JSCompiler_inline_result = describeBuiltInComponentFrame(
575-
entry.name + (env ? " (" + env + ")" : "")
581+
entry.name + (env ? " [" + env + "]" : "")
576582
);
577583
info = JSCompiler_temp_const + JSCompiler_inline_result;
578584
}
@@ -13149,6 +13155,7 @@ __DEV__ &&
1314913155
prevGroupEnd;
1315013156
disabledLog.__reactDisabledLog = !0;
1315113157
var prefix,
13158+
suffix,
1315213159
reentry = !1;
1315313160
var componentFrameCache = new (
1315413161
"function" === typeof WeakMap ? WeakMap : Map
@@ -15072,14 +15079,14 @@ __DEV__ &&
1507215079
scheduleRoot: scheduleRoot,
1507315080
setRefreshHandler: setRefreshHandler,
1507415081
getCurrentFiber: getCurrentFiberForDevTools,
15075-
reconcilerVersion: "19.0.0-native-fb-58af67a8f8-20240628"
15082+
reconcilerVersion: "19.0.0-native-fb-df783f9ea1-20240708"
1507615083
});
1507715084
})({
1507815085
findFiberByHostInstance: function () {
1507915086
throw Error("TestRenderer does not support findFiberByHostInstance()");
1508015087
},
1508115088
bundleType: 1,
15082-
version: "19.0.0-native-fb-58af67a8f8-20240628",
15089+
version: "19.0.0-native-fb-df783f9ea1-20240708",
1508315090
rendererPackageName: "react-test-renderer"
1508415091
});
1508515092
exports._Scheduler = Scheduler;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a230f61eab876a1bf3f5a22ff087160a>>
10+
* @generated SignedSource<<9dcd7685e1640c17fbdf82a52a452035>>
1111
*/
1212

1313
"use strict";
@@ -167,16 +167,23 @@ function getComponentNameFromFiber(fiber) {
167167
}
168168
var ReactSharedInternals =
169169
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
170-
prefix;
170+
prefix,
171+
suffix;
171172
function describeBuiltInComponentFrame(name) {
172173
if (void 0 === prefix)
173174
try {
174175
throw Error();
175176
} catch (x) {
176177
var match = x.stack.trim().match(/\n( *(at )?)/);
177178
prefix = (match && match[1]) || "";
179+
suffix =
180+
-1 < x.stack.indexOf("\n at")
181+
? " (<anonymous>)"
182+
: -1 < x.stack.indexOf("@")
183+
? "@unknown:0:0"
184+
: "";
178185
}
179-
return "\n" + prefix + name;
186+
return "\n" + prefix + name + suffix;
180187
}
181188
var reentry = !1;
182189
function describeNativeComponentFrame(fn, construct) {
@@ -9377,7 +9384,7 @@ var devToolsConfig$jscomp$inline_1053 = {
93779384
throw Error("TestRenderer does not support findFiberByHostInstance()");
93789385
},
93799386
bundleType: 0,
9380-
version: "19.0.0-native-fb-58af67a8f8-20240628",
9387+
version: "19.0.0-native-fb-df783f9ea1-20240708",
93819388
rendererPackageName: "react-test-renderer"
93829389
};
93839390
var internals$jscomp$inline_1240 = {
@@ -9408,7 +9415,7 @@ var internals$jscomp$inline_1240 = {
94089415
scheduleRoot: null,
94099416
setRefreshHandler: null,
94109417
getCurrentFiber: null,
9411-
reconcilerVersion: "19.0.0-native-fb-58af67a8f8-20240628"
9418+
reconcilerVersion: "19.0.0-native-fb-df783f9ea1-20240708"
94129419
};
94139420
if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) {
94149421
var hook$jscomp$inline_1241 = __REACT_DEVTOOLS_GLOBAL_HOOK__;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<8b0fcf879d182dc10c942f445a24f780>>
10+
* @generated SignedSource<<661fb6132400bc6cbf49596db0acc720>>
1111
*/
1212

1313
"use strict";
@@ -167,16 +167,23 @@ function getComponentNameFromFiber(fiber) {
167167
}
168168
var ReactSharedInternals =
169169
React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
170-
prefix;
170+
prefix,
171+
suffix;
171172
function describeBuiltInComponentFrame(name) {
172173
if (void 0 === prefix)
173174
try {
174175
throw Error();
175176
} catch (x) {
176177
var match = x.stack.trim().match(/\n( *(at )?)/);
177178
prefix = (match && match[1]) || "";
179+
suffix =
180+
-1 < x.stack.indexOf("\n at")
181+
? " (<anonymous>)"
182+
: -1 < x.stack.indexOf("@")
183+
? "@unknown:0:0"
184+
: "";
178185
}
179-
return "\n" + prefix + name;
186+
return "\n" + prefix + name + suffix;
180187
}
181188
var reentry = !1;
182189
function describeNativeComponentFrame(fn, construct) {
@@ -9997,7 +10004,7 @@ var devToolsConfig$jscomp$inline_1136 = {
999710004
throw Error("TestRenderer does not support findFiberByHostInstance()");
999810005
},
999910006
bundleType: 0,
10000-
version: "19.0.0-native-fb-58af67a8f8-20240628",
10007+
version: "19.0.0-native-fb-df783f9ea1-20240708",
1000110008
rendererPackageName: "react-test-renderer"
1000210009
};
1000310010
(function (internals) {
@@ -10041,7 +10048,7 @@ var devToolsConfig$jscomp$inline_1136 = {
1004110048
scheduleRoot: null,
1004210049
setRefreshHandler: null,
1004310050
getCurrentFiber: null,
10044-
reconcilerVersion: "19.0.0-native-fb-58af67a8f8-20240628"
10051+
reconcilerVersion: "19.0.0-native-fb-df783f9ea1-20240708"
1004510052
});
1004610053
exports._Scheduler = Scheduler;
1004710054
exports.act = act;

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/JSXDEVRuntime-dev.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<a7dfd81316b971431720d69e9f261fbf>>
10+
* @generated SignedSource<<2e4bfe3b6770b799c0ba60be06b0baca>>
1111
*/
1212

1313
"use strict";
@@ -165,8 +165,14 @@ __DEV__ &&
165165
} catch (x) {
166166
var match = x.stack.trim().match(/\n( *(at )?)/);
167167
prefix = (match && match[1]) || "";
168+
suffix =
169+
-1 < x.stack.indexOf("\n at")
170+
? " (<anonymous>)"
171+
: -1 < x.stack.indexOf("@")
172+
? "@unknown:0:0"
173+
: "";
168174
}
169-
return "\n" + prefix + name;
175+
return "\n" + prefix + name + suffix;
170176
}
171177
function describeNativeComponentFrame(fn, construct) {
172178
if (!fn || reentry) return "";
@@ -670,6 +676,7 @@ __DEV__ &&
670676
prevGroupEnd;
671677
disabledLog.__reactDisabledLog = !0;
672678
var prefix,
679+
suffix,
673680
reentry = !1;
674681
var componentFrameCache = new (
675682
"function" === typeof WeakMap ? WeakMap : Map

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/JSXRuntime-dev.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<1e831dc318079da75149235e0e09d92d>>
10+
* @generated SignedSource<<7ad8e11753e71d86731728e561f85039>>
1111
*/
1212

1313
"use strict";
@@ -165,8 +165,14 @@ __DEV__ &&
165165
} catch (x) {
166166
var match = x.stack.trim().match(/\n( *(at )?)/);
167167
prefix = (match && match[1]) || "";
168+
suffix =
169+
-1 < x.stack.indexOf("\n at")
170+
? " (<anonymous>)"
171+
: -1 < x.stack.indexOf("@")
172+
? "@unknown:0:0"
173+
: "";
168174
}
169-
return "\n" + prefix + name;
175+
return "\n" + prefix + name + suffix;
170176
}
171177
function describeNativeComponentFrame(fn, construct) {
172178
if (!fn || reentry) return "";
@@ -670,6 +676,7 @@ __DEV__ &&
670676
prevGroupEnd;
671677
disabledLog.__reactDisabledLog = !0;
672678
var prefix,
679+
suffix,
673680
reentry = !1;
674681
var componentFrameCache = new (
675682
"function" === typeof WeakMap ? WeakMap : Map

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<63806b4788513932e73deffcc14466b6>>
10+
* @generated SignedSource<<eee457cdc760bc83f6841edabd786565>>
1111
*/
1212

1313
"use strict";
@@ -245,8 +245,14 @@ __DEV__ &&
245245
} catch (x) {
246246
var match = x.stack.trim().match(/\n( *(at )?)/);
247247
prefix = (match && match[1]) || "";
248+
suffix =
249+
-1 < x.stack.indexOf("\n at")
250+
? " (<anonymous>)"
251+
: -1 < x.stack.indexOf("@")
252+
? "@unknown:0:0"
253+
: "";
248254
}
249-
return "\n" + prefix + name;
255+
return "\n" + prefix + name + suffix;
250256
}
251257
function describeNativeComponentFrame(fn, construct) {
252258
if (!fn || reentry) return "";
@@ -1125,6 +1131,7 @@ __DEV__ &&
11251131
prevGroupEnd;
11261132
disabledLog.__reactDisabledLog = !0;
11271133
var prefix,
1134+
suffix,
11281135
reentry = !1;
11291136
var componentFrameCache = new (
11301137
"function" === typeof WeakMap ? WeakMap : Map
@@ -1741,7 +1748,7 @@ __DEV__ &&
17411748
exports.useTransition = function () {
17421749
return resolveDispatcher().useTransition();
17431750
};
1744-
exports.version = "19.0.0-native-fb-58af67a8f8-20240628";
1751+
exports.version = "19.0.0-native-fb-df783f9ea1-20240708";
17451752
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
17461753
"function" ===
17471754
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<6e39ee5928417fc3a4496375cf39d2ca>>
10+
* @generated SignedSource<<7c12730813cc8752d34681669dee99a2>>
1111
*/
1212

1313
"use strict";
@@ -604,4 +604,4 @@ exports.useSyncExternalStore = function (
604604
exports.useTransition = function () {
605605
return ReactSharedInternals.H.useTransition();
606606
};
607-
exports.version = "19.0.0-native-fb-58af67a8f8-20240628";
607+
exports.version = "19.0.0-native-fb-df783f9ea1-20240708";

compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<507175890e1729117769a5cffe8b37a0>>
10+
* @generated SignedSource<<157ac3b6e8ae340940bc85ec2c3806cc>>
1111
*/
1212

1313
"use strict";
@@ -608,7 +608,7 @@ exports.useSyncExternalStore = function (
608608
exports.useTransition = function () {
609609
return ReactSharedInternals.H.useTransition();
610610
};
611-
exports.version = "19.0.0-native-fb-58af67a8f8-20240628";
611+
exports.version = "19.0.0-native-fb-df783f9ea1-20240708";
612612
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
613613
"function" ===
614614
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
58af67a8f8761e56b5d02486a304c96edc547760
1+
df783f9ea1b6f95e05f830602da1de5ffb325d30

compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @noflow
88
* @nolint
99
* @preventMunge
10-
* @generated SignedSource<<b26df307c5e29739cf9da04a9ae90101>>
10+
* @generated SignedSource<<cb3e48516a63e1d432c10d2a36d40a98>>
1111
*/
1212

1313
"use strict";
@@ -225,8 +225,14 @@ __DEV__ &&
225225
} catch (x) {
226226
var match = x.stack.trim().match(/\n( *(at )?)/);
227227
prefix = (match && match[1]) || "";
228+
suffix =
229+
-1 < x.stack.indexOf("\n at")
230+
? " (<anonymous>)"
231+
: -1 < x.stack.indexOf("@")
232+
? "@unknown:0:0"
233+
: "";
228234
}
229-
return "\n" + prefix + name;
235+
return "\n" + prefix + name + suffix;
230236
}
231237
function describeNativeComponentFrame(fn, construct) {
232238
if (!fn || reentry) return "";
@@ -440,7 +446,7 @@ __DEV__ &&
440446
var JSCompiler_temp_const = info,
441447
env = entry.env;
442448
var JSCompiler_inline_result = describeBuiltInComponentFrame(
443-
entry.name + (env ? " (" + env + ")" : "")
449+
entry.name + (env ? " [" + env + "]" : "")
444450
);
445451
info = JSCompiler_temp_const + JSCompiler_inline_result;
446452
}
@@ -14163,6 +14169,7 @@ __DEV__ &&
1416314169
prevGroupEnd;
1416414170
disabledLog.__reactDisabledLog = !0;
1416514171
var prefix,
14172+
suffix,
1416614173
reentry = !1;
1416714174
var componentFrameCache = new (
1416814175
"function" === typeof WeakMap ? WeakMap : Map
@@ -16679,12 +16686,12 @@ __DEV__ &&
1667916686
scheduleRoot: scheduleRoot,
1668016687
setRefreshHandler: setRefreshHandler,
1668116688
getCurrentFiber: getCurrentFiberForDevTools,
16682-
reconcilerVersion: "19.0.0-native-fb-58af67a8f8-20240628"
16689+
reconcilerVersion: "19.0.0-native-fb-df783f9ea1-20240708"
1668316690
});
1668416691
})({
1668516692
findFiberByHostInstance: getInstanceFromNode,
1668616693
bundleType: 1,
16687-
version: "19.0.0-native-fb-58af67a8f8-20240628",
16694+
version: "19.0.0-native-fb-df783f9ea1-20240708",
1668816695
rendererPackageName: "react-native-renderer",
1668916696
rendererConfig: {
1669016697
getInspectorDataForInstance: getInspectorDataForInstance,

0 commit comments

Comments
 (0)