Skip to content

Commit a8c869c

Browse files
committed
fix: rename bottom stack frame
1 parent 7216c0f commit a8c869c

File tree

9 files changed

+48
-41
lines changed

9 files changed

+48
-41
lines changed

packages/react-client/src/ReactFlightClient.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2947,7 +2947,7 @@ function buildFakeTask(
29472947
}
29482948

29492949
const createFakeJSXCallStack = {
2950-
'react-stack-bottom-frame': function (
2950+
react_stack_bottom_frame: function (
29512951
response: Response,
29522952
stack: ReactStackTrace,
29532953
environmentName: string,
@@ -2969,7 +2969,7 @@ const createFakeJSXCallStackInDEV: (
29692969
environmentName: string,
29702970
) => Error = __DEV__
29712971
? // We use this technique to trick minifiers to preserve the function name.
2972-
(createFakeJSXCallStack['react-stack-bottom-frame'].bind(
2972+
(createFakeJSXCallStack.react_stack_bottom_frame.bind(
29732973
createFakeJSXCallStack,
29742974
): any)
29752975
: (null: any);
@@ -3083,7 +3083,7 @@ function getCurrentStackInDEV(): string {
30833083
}
30843084

30853085
const replayConsoleWithCallStack = {
3086-
'react-stack-bottom-frame': function (
3086+
react_stack_bottom_frame: function (
30873087
response: Response,
30883088
methodName: string,
30893089
stackTrace: ReactStackTrace,
@@ -3135,7 +3135,7 @@ const replayConsoleWithCallStackInDEV: (
31353135
args: Array<mixed>,
31363136
) => void = __DEV__
31373137
? // We use this technique to trick minifiers to preserve the function name.
3138-
(replayConsoleWithCallStack['react-stack-bottom-frame'].bind(
3138+
(replayConsoleWithCallStack.react_stack_bottom_frame.bind(
31393139
replayConsoleWithCallStack,
31403140
): any)
31413141
: (null: any);

packages/react-devtools-shared/src/backend/shared/DevToolsOwnerStack.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ export function formatOwnerStackString(stack: string): string {
2929
// Pop the JSX frame.
3030
stack = stack.slice(idx + 1);
3131
}
32-
idx = stack.indexOf('react-stack-bottom-frame');
32+
idx = stack.indexOf('react_stack_bottom_frame');
33+
if (idx === -1) {
34+
idx = stack.indexOf('react-stack-bottom-frame');
35+
}
3336
if (idx !== -1) {
3437
idx = stack.lastIndexOf('\n', idx);
3538
}

packages/react-devtools-shared/src/backend/utils/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,11 @@ function collectStackTrace(
358358
// We mirror how V8 serializes stack frames and how we later parse them.
359359
for (let i = 0; i < structuredStackTrace.length; i++) {
360360
const callSite = structuredStackTrace[i];
361-
if (callSite.getFunctionName() === 'react-stack-bottom-frame') {
361+
const name = callSite.getFunctionName();
362+
if (
363+
name.includes('react_stack_bottom_frame') ||
364+
name.includes('react-stack-bottom-frame')
365+
) {
362366
// We pick the last frame that matches before the bottom frame since
363367
// that will be immediately inside the component as opposed to some helper.
364368
// If we don't find a bottom frame then we bail to string parsing.

packages/react-reconciler/src/ReactFiberCallUserSpace.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {captureCommitPhaseError} from './ReactFiberWorkLoop';
1919
// TODO: Consider marking the whole bundle instead of these boundaries.
2020

2121
const callComponent = {
22-
'react-stack-bottom-frame': function <Props, Arg, R>(
22+
react_stack_bottom_frame: function <Props, Arg, R>(
2323
Component: (p: Props, arg: Arg) => R,
2424
props: Props,
2525
secondArg: Arg,
@@ -41,7 +41,7 @@ export const callComponentInDEV: <Props, Arg, R>(
4141
secondArg: Arg,
4242
) => R = __DEV__
4343
? // We use this technique to trick minifiers to preserve the function name.
44-
(callComponent['react-stack-bottom-frame'].bind(callComponent): any)
44+
(callComponent.react_stack_bottom_frame.bind(callComponent): any)
4545
: (null: any);
4646

4747
interface ClassInstance<R> {
@@ -57,7 +57,7 @@ interface ClassInstance<R> {
5757
}
5858

5959
const callRender = {
60-
'react-stack-bottom-frame': function <R>(instance: ClassInstance<R>): R {
60+
react_stack_bottom_frame: function <R>(instance: ClassInstance<R>): R {
6161
const wasRendering = isRendering;
6262
setIsRendering(true);
6363
try {
@@ -72,11 +72,11 @@ const callRender = {
7272
export const callRenderInDEV: <R>(instance: ClassInstance<R>) => R => R =
7373
__DEV__
7474
? // We use this technique to trick minifiers to preserve the function name.
75-
(callRender['react-stack-bottom-frame'].bind(callRender): any)
75+
(callRender.react_stack_bottom_frame.bind(callRender): any)
7676
: (null: any);
7777

7878
const callComponentDidMount = {
79-
'react-stack-bottom-frame': function (
79+
react_stack_bottom_frame: function (
8080
finishedWork: Fiber,
8181
instance: ClassInstance<any>,
8282
): void {
@@ -93,13 +93,13 @@ export const callComponentDidMountInDEV: (
9393
instance: ClassInstance<any>,
9494
) => void = __DEV__
9595
? // We use this technique to trick minifiers to preserve the function name.
96-
(callComponentDidMount['react-stack-bottom-frame'].bind(
96+
(callComponentDidMount.react_stack_bottom_frame.bind(
9797
callComponentDidMount,
9898
): any)
9999
: (null: any);
100100

101101
const callComponentDidUpdate = {
102-
'react-stack-bottom-frame': function (
102+
react_stack_bottom_frame: function (
103103
finishedWork: Fiber,
104104
instance: ClassInstance<any>,
105105
prevProps: Object,
@@ -122,13 +122,13 @@ export const callComponentDidUpdateInDEV: (
122122
snaphot: Object,
123123
) => void = __DEV__
124124
? // We use this technique to trick minifiers to preserve the function name.
125-
(callComponentDidUpdate['react-stack-bottom-frame'].bind(
125+
(callComponentDidUpdate.react_stack_bottom_frame.bind(
126126
callComponentDidUpdate,
127127
): any)
128128
: (null: any);
129129

130130
const callComponentDidCatch = {
131-
'react-stack-bottom-frame': function (
131+
react_stack_bottom_frame: function (
132132
instance: ClassInstance<any>,
133133
errorInfo: CapturedValue<mixed>,
134134
): void {
@@ -145,13 +145,13 @@ export const callComponentDidCatchInDEV: (
145145
errorInfo: CapturedValue<mixed>,
146146
) => void = __DEV__
147147
? // We use this technique to trick minifiers to preserve the function name.
148-
(callComponentDidCatch['react-stack-bottom-frame'].bind(
148+
(callComponentDidCatch.react_stack_bottom_frame.bind(
149149
callComponentDidCatch,
150150
): any)
151151
: (null: any);
152152

153153
const callComponentWillUnmount = {
154-
'react-stack-bottom-frame': function (
154+
react_stack_bottom_frame: function (
155155
current: Fiber,
156156
nearestMountedAncestor: Fiber | null,
157157
instance: ClassInstance<any>,
@@ -170,13 +170,13 @@ export const callComponentWillUnmountInDEV: (
170170
instance: ClassInstance<any>,
171171
) => void = __DEV__
172172
? // We use this technique to trick minifiers to preserve the function name.
173-
(callComponentWillUnmount['react-stack-bottom-frame'].bind(
173+
(callComponentWillUnmount.react_stack_bottom_frame.bind(
174174
callComponentWillUnmount,
175175
): any)
176176
: (null: any);
177177

178178
const callCreate = {
179-
'react-stack-bottom-frame': function (
179+
react_stack_bottom_frame: function (
180180
effect: Effect,
181181
): (() => void) | {...} | void | null {
182182
const create = effect.create;
@@ -189,11 +189,11 @@ const callCreate = {
189189

190190
export const callCreateInDEV: (effect: Effect) => (() => void) | void = __DEV__
191191
? // We use this technique to trick minifiers to preserve the function name.
192-
(callCreate['react-stack-bottom-frame'].bind(callCreate): any)
192+
(callCreate.react_stack_bottom_frame.bind(callCreate): any)
193193
: (null: any);
194194

195195
const callDestroy = {
196-
'react-stack-bottom-frame': function (
196+
react_stack_bottom_frame: function (
197197
current: Fiber,
198198
nearestMountedAncestor: Fiber | null,
199199
destroy: () => void,
@@ -212,11 +212,11 @@ export const callDestroyInDEV: (
212212
destroy: (() => void) | (({...}) => void),
213213
) => void = __DEV__
214214
? // We use this technique to trick minifiers to preserve the function name.
215-
(callDestroy['react-stack-bottom-frame'].bind(callDestroy): any)
215+
(callDestroy.react_stack_bottom_frame.bind(callDestroy): any)
216216
: (null: any);
217217

218218
const callLazyInit = {
219-
'react-stack-bottom-frame': function (lazy: LazyComponent<any, any>): any {
219+
react_stack_bottom_frame: function (lazy: LazyComponent<any, any>): any {
220220
const payload = lazy._payload;
221221
const init = lazy._init;
222222
return init(payload);
@@ -225,5 +225,5 @@ const callLazyInit = {
225225

226226
export const callLazyInitInDEV: (lazy: LazyComponent<any, any>) => any = __DEV__
227227
? // We use this technique to trick minifiers to preserve the function name.
228-
(callLazyInit['react-stack-bottom-frame'].bind(callLazyInit): any)
228+
(callLazyInit.react_stack_bottom_frame.bind(callLazyInit): any)
229229
: (null: any);

packages/react-server/src/ReactFizzCallUserSpace.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import type {LazyComponent} from 'react/src/ReactLazy';
1313
// TODO: Consider marking the whole bundle instead of these boundaries.
1414

1515
const callComponent = {
16-
'react-stack-bottom-frame': function <Props, Arg, R>(
16+
react_stack_bottom_frame: function <Props, Arg, R>(
1717
Component: (p: Props, arg: Arg) => R,
1818
props: Props,
1919
secondArg: Arg,
@@ -28,27 +28,27 @@ export const callComponentInDEV: <Props, Arg, R>(
2828
secondArg: Arg,
2929
) => R = __DEV__
3030
? // We use this technique to trick minifiers to preserve the function name.
31-
(callComponent['react-stack-bottom-frame'].bind(callComponent): any)
31+
(callComponent.react_stack_bottom_frame.bind(callComponent): any)
3232
: (null: any);
3333

3434
interface ClassInstance<R> {
3535
render(): R;
3636
}
3737

3838
const callRender = {
39-
'react-stack-bottom-frame': function <R>(instance: ClassInstance<R>): R {
39+
react_stack_bottom_frame: function <R>(instance: ClassInstance<R>): R {
4040
return instance.render();
4141
},
4242
};
4343

4444
export const callRenderInDEV: <R>(instance: ClassInstance<R>) => R => R =
4545
__DEV__
4646
? // We use this technique to trick minifiers to preserve the function name.
47-
(callRender['react-stack-bottom-frame'].bind(callRender): any)
47+
(callRender.react_stack_bottom_frame.bind(callRender): any)
4848
: (null: any);
4949

5050
const callLazyInit = {
51-
'react-stack-bottom-frame': function (lazy: LazyComponent<any, any>): any {
51+
react_stack_bottom_frame: function (lazy: LazyComponent<any, any>): any {
5252
const payload = lazy._payload;
5353
const init = lazy._init;
5454
return init(payload);
@@ -57,5 +57,5 @@ const callLazyInit = {
5757

5858
export const callLazyInitInDEV: (lazy: LazyComponent<any, any>) => any = __DEV__
5959
? // We use this technique to trick minifiers to preserve the function name.
60-
(callLazyInit['react-stack-bottom-frame'].bind(callLazyInit): any)
60+
(callLazyInit.react_stack_bottom_frame.bind(callLazyInit): any)
6161
: (null: any);

packages/react-server/src/ReactFlightCallUserSpace.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {setCurrentOwner} from './flight/ReactFlightCurrentOwner';
1919
// TODO: Consider marking the whole bundle instead of these boundaries.
2020

2121
const callComponent = {
22-
'react-stack-bottom-frame': function <Props, R>(
22+
react_stack_bottom_frame: function <Props, R>(
2323
Component: (p: Props, arg: void) => R,
2424
props: Props,
2525
componentDebugInfo: ReactComponentInfo,
@@ -41,11 +41,11 @@ export const callComponentInDEV: <Props, R>(
4141
componentDebugInfo: ReactComponentInfo,
4242
) => R = __DEV__
4343
? // We use this technique to trick minifiers to preserve the function name.
44-
(callComponent['react-stack-bottom-frame'].bind(callComponent): any)
44+
(callComponent.react_stack_bottom_frame.bind(callComponent): any)
4545
: (null: any);
4646

4747
const callLazyInit = {
48-
'react-stack-bottom-frame': function (lazy: LazyComponent<any, any>): any {
48+
react_stack_bottom_frame: function (lazy: LazyComponent<any, any>): any {
4949
const payload = lazy._payload;
5050
const init = lazy._init;
5151
return init(payload);
@@ -54,11 +54,11 @@ const callLazyInit = {
5454

5555
export const callLazyInitInDEV: (lazy: LazyComponent<any, any>) => any = __DEV__
5656
? // We use this technique to trick minifiers to preserve the function name.
57-
(callLazyInit['react-stack-bottom-frame'].bind(callLazyInit): any)
57+
(callLazyInit.react_stack_bottom_frame.bind(callLazyInit): any)
5858
: (null: any);
5959

6060
const callIterator = {
61-
'react-stack-bottom-frame': function (
61+
react_stack_bottom_frame: function (
6262
iterator: $AsyncIterator<ReactClientValue, ReactClientValue, void>,
6363
progress: (
6464
entry:
@@ -81,5 +81,5 @@ export const callIteratorInDEV: (
8181
error: (reason: mixed) => void,
8282
) => void = __DEV__
8383
? // We use this technique to trick minifiers to preserve the function name.
84-
(callIterator['react-stack-bottom-frame'].bind(callIterator): any)
84+
(callIterator.react_stack_bottom_frame.bind(callIterator): any)
8585
: (null: any);

packages/react-server/src/ReactFlightStackConfigV8.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function collectStackTrace(
5959
for (let i = framesToSkip; i < structuredStackTrace.length; i++) {
6060
const callSite = structuredStackTrace[i];
6161
let name = callSite.getFunctionName() || '<anonymous>';
62-
if (name === 'react-stack-bottom-frame') {
62+
if (name.includes('react_stack_bottom_frame')) {
6363
// Skip everything after the bottom frame since it'll be internals.
6464
break;
6565
} else if (callSite.isNative()) {
@@ -174,7 +174,7 @@ export function parseStackTrace(
174174
// don't want/need.
175175
stack = stack.slice(29);
176176
}
177-
let idx = stack.indexOf('react-stack-bottom-frame');
177+
let idx = stack.indexOf('react_stack_bottom_frame');
178178
if (idx !== -1) {
179179
idx = stack.lastIndexOf('\n', idx);
180180
}

packages/react/src/jsx/ReactJSXElement.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function UnknownOwner() {
6666
return (() => Error('react-stack-top-frame'))();
6767
}
6868
const createFakeCallStack = {
69-
'react-stack-bottom-frame': function (callStackForError) {
69+
react_stack_bottom_frame: function (callStackForError) {
7070
return callStackForError();
7171
},
7272
};
@@ -81,7 +81,7 @@ if (__DEV__) {
8181
didWarnAboutElementRef = {};
8282

8383
// We use this technique to trick minifiers to preserve the function name.
84-
unknownOwnerDebugStack = createFakeCallStack['react-stack-bottom-frame'].bind(
84+
unknownOwnerDebugStack = createFakeCallStack.react_stack_bottom_frame.bind(
8585
createFakeCallStack,
8686
UnknownOwner,
8787
)();

packages/shared/ReactOwnerStackFrames.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function formatOwnerStack(error: Error): string {
2424
// Pop the JSX frame.
2525
stack = stack.slice(idx + 1);
2626
}
27-
idx = stack.indexOf('react-stack-bottom-frame');
27+
idx = stack.indexOf('react_stack_bottom_frame');
2828
if (idx !== -1) {
2929
idx = stack.lastIndexOf('\n', idx);
3030
}

0 commit comments

Comments
 (0)