(root, thrownValue)
| 26271 | } |
| 26272 | |
| 26273 | function handleError(root, thrownValue) { |
| 26274 | do { |
| 26275 | var erroredWork = workInProgress; |
| 26276 | |
| 26277 | try { |
| 26278 | // Reset module-level state that was set during the render phase. |
| 26279 | resetContextDependencies(); |
| 26280 | resetHooksAfterThrow(); |
| 26281 | resetCurrentFiber(); // TODO: I found and added this missing line while investigating a |
| 26282 | // separate issue. Write a regression test using string refs. |
| 26283 | |
| 26284 | ReactCurrentOwner$2.current = null; |
| 26285 | |
| 26286 | if (erroredWork === null || erroredWork.return === null) { |
| 26287 | // Expected to be working on a non-root fiber. This is a fatal error |
| 26288 | // because there's no ancestor that can handle it; the root is |
| 26289 | // supposed to capture all errors that weren't caught by an error |
| 26290 | // boundary. |
| 26291 | workInProgressRootExitStatus = RootFatalErrored; |
| 26292 | workInProgressRootFatalError = thrownValue; // Set `workInProgress` to null. This represents advancing to the next |
| 26293 | // sibling, or the parent if there are no siblings. But since the root |
| 26294 | // has no siblings nor a parent, we set it to null. Usually this is |
| 26295 | // handled by `completeUnitOfWork` or `unwindWork`, but since we're |
| 26296 | // intentionally not calling those, we need set it here. |
| 26297 | // TODO: Consider calling `unwindWork` to pop the contexts. |
| 26298 | |
| 26299 | workInProgress = null; |
| 26300 | return; |
| 26301 | } |
| 26302 | |
| 26303 | if (enableProfilerTimer && erroredWork.mode & ProfileMode) { |
| 26304 | // Record the time spent rendering before an error was thrown. This |
| 26305 | // avoids inaccurate Profiler durations in the case of a |
| 26306 | // suspended render. |
| 26307 | stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); |
| 26308 | } |
| 26309 | |
| 26310 | if (enableSchedulingProfiler) { |
| 26311 | markComponentRenderStopped(); |
| 26312 | |
| 26313 | if (thrownValue !== null && typeof thrownValue === 'object' && typeof thrownValue.then === 'function') { |
| 26314 | var wakeable = thrownValue; |
| 26315 | markComponentSuspended(erroredWork, wakeable, workInProgressRootRenderLanes); |
| 26316 | } else { |
| 26317 | markComponentErrored(erroredWork, thrownValue, workInProgressRootRenderLanes); |
| 26318 | } |
| 26319 | } |
| 26320 | |
| 26321 | throwException(root, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes); |
| 26322 | completeUnitOfWork(erroredWork); |
| 26323 | } catch (yetAnotherThrownValue) { |
| 26324 | // Something in the return path also threw. |
| 26325 | thrownValue = yetAnotherThrownValue; |
| 26326 | |
| 26327 | if (workInProgress === erroredWork && erroredWork !== null) { |
| 26328 | // If this boundary has already errored, then we had trouble processing |
| 26329 | // the error. Bubble it to the next boundary. |
| 26330 | erroredWork = erroredWork.return; |
no test coverage detected
searching dependent graphs…