File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
packages/react-server/src Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -152,11 +152,20 @@ function defaultFilterStackFrame(
152
152
) ;
153
153
}
154
154
155
+ // DEV-only cache of parsed and filtered stack frames.
156
+ const stackTraceCache: WeakMap< Error , ReactStackTrace > = __DEV__
157
+ ? new WeakMap()
158
+ : (null: any);
159
+
155
160
function filterStackTrace(
156
161
request: Request,
157
162
error: Error,
158
163
skipFrames: number,
159
164
): ReactStackTrace {
165
+ const existing = stackTraceCache . get ( error ) ;
166
+ if ( existing !== undefined ) {
167
+ return existing ;
168
+ }
160
169
// Since stacks can be quite large and we pass a lot of them, we filter them out eagerly
161
170
// to save bandwidth even in DEV. We'll also replay these stacks on the client so by
162
171
// stripping them early we avoid that overhead. Otherwise we'd normally just rely on
@@ -183,6 +192,7 @@ function filterStackTrace(
183
192
i -- ;
184
193
}
185
194
}
195
+ stackTraceCache . set ( error , stack ) ;
186
196
return stack ;
187
197
}
188
198
You can’t perform that action at this time.
0 commit comments