mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Honor ignored frames in errors reported by Fantom (#52765)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52765 Changelog: [internal] Reported locations for errors in Fantom is wrong, because it seems it's not ignoring "infra" frames. This was caused by the `stack` property in `ErrorWithCustomBlame` being set on the error objects and shadowing the getter that removes the necessary frames. This fixes that by forcing that property to be deleted. Reviewed By: christophpurrer Differential Revision: D78747119 fbshipit-source-id: 81d6ce74041382d7582e2066409e839d28d91052
This commit is contained in:
committed by
Facebook GitHub Bot
parent
c97741da39
commit
af670c8319
+13
@@ -24,6 +24,15 @@ class ErrorWithCustomBlame extends Error {
|
||||
#cachedProcessedStack: ?string;
|
||||
#customStack: ?string;
|
||||
|
||||
constructor(message?: string, options?: {cause?: mixed, ...}) {
|
||||
super(message, options);
|
||||
|
||||
// The Error constructor forces an own `stack` property that shadows our
|
||||
// getter, so deleting it restores that behavior.
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
delete this.stack;
|
||||
}
|
||||
|
||||
blameToPreviousFrame(): this {
|
||||
this.#cachedProcessedStack = null;
|
||||
this.#ignoredFrameCount++;
|
||||
@@ -34,6 +43,10 @@ class ErrorWithCustomBlame extends Error {
|
||||
get stack(): string {
|
||||
if (this.#cachedProcessedStack == null) {
|
||||
const originalStack = this.#customStack ?? super.stack;
|
||||
// Calling `super.stack` forces an own `stack` property that shadows our
|
||||
// getter, so deleting it restores that behavior.
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
delete this.stack;
|
||||
|
||||
const lines = originalStack.split('\n');
|
||||
const index = lines.findIndex(line =>
|
||||
|
||||
Reference in New Issue
Block a user