File tree Expand file tree Collapse file tree 2 files changed +24
-12
lines changed
packages/scheduler/src/forks Expand file tree Collapse file tree 2 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -519,8 +519,13 @@ const performWorkUntilDeadline = () => {
519
519
// the message event.
520
520
deadline = currentTime + yieldInterval ;
521
521
const hasTimeRemaining = true ;
522
+
523
+ // Use a variable to track whether something task throws, instead of a try-
524
+ // catch, since that makes some debugging techniques harder.
525
+ let didError = true ;
522
526
try {
523
527
const hasMoreWork = scheduledHostCallback ( hasTimeRemaining , currentTime ) ;
528
+ didError = false ;
524
529
if ( ! hasMoreWork ) {
525
530
isMessageLoopRunning = false ;
526
531
scheduledHostCallback = null ;
@@ -529,11 +534,12 @@ const performWorkUntilDeadline = () => {
529
534
// of the preceding one.
530
535
port . postMessage ( null ) ;
531
536
}
532
- } catch ( error ) {
533
- // If a scheduler task throws, exit the current browser task so the
534
- // error can be observed.
535
- port . postMessage ( null ) ;
536
- throw error ;
537
+ } finally {
538
+ if ( didError ) {
539
+ // If a scheduler task throws, exit the current browser task so the
540
+ // error can be observed.
541
+ port . postMessage ( null ) ;
542
+ }
537
543
}
538
544
} else {
539
545
isMessageLoopRunning = false ;
Original file line number Diff line number Diff line change @@ -512,21 +512,27 @@ const performWorkUntilDeadline = () => {
512
512
// the message event.
513
513
deadline = currentTime + yieldInterval ;
514
514
const hasTimeRemaining = true ;
515
+
516
+ // Use a variable to track whether something task throws, instead of a try-
517
+ // catch, since that makes some debugging techniques harder.
518
+ let didError = true ;
515
519
try {
516
520
const hasMoreWork = scheduledHostCallback ( hasTimeRemaining , currentTime ) ;
521
+ didError = false ;
517
522
if ( ! hasMoreWork ) {
518
523
isTaskLoopRunning = false ;
519
524
scheduledHostCallback = null ;
520
525
} else {
521
- // If there's more work, schedule the next message event at the end
522
- // of the preceding one.
526
+ // If there's more work, schedule the next browser task at the end of
527
+ // the preceding one.
528
+ postTask ( performWorkUntilDeadline ) ;
529
+ }
530
+ } finally {
531
+ if ( didError ) {
532
+ // If a scheduler task throws, exit the current browser task so the
533
+ // error can be observed.
523
534
postTask ( performWorkUntilDeadline ) ;
524
535
}
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
536
}
531
537
} else {
532
538
isTaskLoopRunning = false ;
You can’t perform that action at this time.
0 commit comments