Skip to content

Commit

Permalink
Extract throw to separate function so performUnitOfWork does not deopt (
Browse files Browse the repository at this point in the history
#12521)

Only affects DEV mode, but still important I think.
  • Loading branch information
acdlite authored and gaearon committed Apr 3, 2018
1 parent 4ccf58a commit 6f2ea73
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
let replayUnitOfWork;
let isReplayingFailedUnitOfWork;
let originalReplayError;
let rethrowOriginalError;
if (__DEV__ && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
stashedWorkInProgressProperties = null;
isReplayingFailedUnitOfWork = false;
Expand Down Expand Up @@ -311,6 +312,9 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
nextUnitOfWork = failedUnitOfWork;
}
};
rethrowOriginalError = () => {
throw originalReplayError;
};
}

function resetStack() {
Expand Down Expand Up @@ -875,7 +879,7 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
// because the render phase is meant to be idempotent, and it should
// have thrown again. Since it didn't, rethrow the original error, so
// React's internal stack is not misaligned.
throw originalReplayError;
rethrowOriginalError();
}
}
if (__DEV__ && ReactFiberInstrumentation.debugTool) {
Expand Down

0 comments on commit 6f2ea73

Please sign in to comment.