@@ -512,21 +512,25 @@ const performWorkUntilDeadline = () => {
512
512
// the message event.
513
513
deadline = currentTime + yieldInterval ;
514
514
const hasTimeRemaining = true ;
515
+
516
+ // If a scheduler task throws, exit the current browser task so the
517
+ // error can be observed.
518
+ //
519
+ // Intentionally not using a try-catch, since that makes some debugging
520
+ // techniques harder. Instead, if `scheduledHostCallback` errors, then
521
+ // `hasMoreWork` will remain true, and we'll continue the work loop.
522
+ let hasMoreWork = true ;
515
523
try {
516
- const hasMoreWork = scheduledHostCallback ( hasTimeRemaining , currentTime ) ;
517
- if ( ! hasMoreWork ) {
524
+ hasMoreWork = scheduledHostCallback ( hasTimeRemaining , currentTime ) ;
525
+ } finally {
526
+ if ( hasMoreWork ) {
527
+ // If there's more work, schedule the next browser task at the end of
528
+ // the preceding one.
529
+ postTask ( performWorkUntilDeadline ) ;
530
+ } else {
518
531
isTaskLoopRunning = false ;
519
532
scheduledHostCallback = null ;
520
- } else {
521
- // If there's more work, schedule the next message event at the end
522
- // of the preceding one.
523
- postTask ( performWorkUntilDeadline ) ;
524
533
}
525
- } catch ( error ) {
526
- // If a scheduler task throws, exit the current browser task so the
527
- // error can be observed.
528
- postTask ( performWorkUntilDeadline ) ;
529
- throw error ;
530
534
}
531
535
} else {
532
536
isTaskLoopRunning = false ;
0 commit comments