-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move error logging to update callback
This prevents double logging for gDSFE boundaries with createRoot.
- Loading branch information
Showing
3 changed files
with
15 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,9 +108,14 @@ function createClassErrorUpdate( | |
if (typeof getDerivedStateFromError === 'function') { | ||
const error = errorInfo.value; | ||
update.payload = () => { | ||
logCapturedError(fiber, errorInfo); | ||
return getDerivedStateFromError(error); | ||
}; | ||
update.callback = () => { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if (__DEV__) { | ||
markFailedErrorBoundaryForHotReloading(fiber); | ||
} | ||
logCapturedError(fiber, errorInfo); | ||
}; | ||
} | ||
|
||
const inst = fiber.stateNode; | ||
|
@@ -119,16 +124,14 @@ function createClassErrorUpdate( | |
if (__DEV__) { | ||
markFailedErrorBoundaryForHotReloading(fiber); | ||
} | ||
logCapturedError(fiber, errorInfo); | ||
This comment has been minimized.
Sorry, something went wrong.
gaearon
Author
Collaborator
|
||
if (typeof getDerivedStateFromError !== 'function') { | ||
// To preserve the preexisting retry behavior of error boundaries, | ||
// we keep track of which ones already failed during this batch. | ||
// This gets reset before we yield back to the browser. | ||
// TODO: Warn in strict mode if getDerivedStateFromError is | ||
// not defined. | ||
markLegacyErrorBoundaryAsFailed(this); | ||
|
||
// Only log here if componentDidCatch is the only error boundary method defined | ||
logCapturedError(fiber, errorInfo); | ||
} | ||
const error = errorInfo.value; | ||
const stack = errorInfo.stack; | ||
|
@@ -150,10 +153,6 @@ function createClassErrorUpdate( | |
} | ||
} | ||
}; | ||
} else if (__DEV__) { | ||
update.callback = () => { | ||
markFailedErrorBoundaryForHotReloading(fiber); | ||
}; | ||
} | ||
return update; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Moving the block from below. It used to be DEV-only for gDSFE but now there's a line that has PROD too.