55} from '../client/vnode' ;
66import { Task , TaskFlags } from '../use/use-task' ;
77import type { QRLInternal } from './qrl/qrl-class' ;
8- import type { Chore } from './scheduler' ;
8+ import { ChoreState , type Chore } from './scheduler' ;
99import type { Container , HostElement } from './types' ;
1010import { ChoreType } from './util-chore-type' ;
1111import { ELEMENT_SEQ } from './utils/markers' ;
@@ -147,7 +147,8 @@ function findAncestorBlockingChore(chore: Chore, type: ChoreSetType): Chore | nu
147147 blockingChore . $type$ < ChoreType . VISIBLE &&
148148 blockingChore . $type$ !== ChoreType . TASK &&
149149 blockingChore . $type$ !== ChoreType . QRL_RESOLVE &&
150- blockingChore . $type$ !== ChoreType . RUN_QRL
150+ blockingChore . $type$ !== ChoreType . RUN_QRL &&
151+ blockingChore . $state$ === ChoreState . NONE
151152 ) {
152153 return blockingChore ;
153154 }
@@ -161,7 +162,7 @@ function findAncestorBlockingChore(chore: Chore, type: ChoreSetType): Chore | nu
161162export function findBlockingChore (
162163 chore : Chore ,
163164 choreQueue : ChoreArray ,
164- blockedChores : Set < Chore > ,
165+ blockedChores : ChoreArray ,
165166 runningChores : Set < Chore > ,
166167 container : Container
167168) : Chore | null {
@@ -185,20 +186,32 @@ export function findBlockingChore(
185186 // Check in choreQueue
186187 // TODO(perf): better to iterate in reverse order?
187188 for ( const candidate of choreQueue ) {
188- if ( candidate . $type$ === rule . blockingType && rule . match ( chore , candidate , container ) ) {
189+ if (
190+ candidate . $type$ === rule . blockingType &&
191+ rule . match ( chore , candidate , container ) &&
192+ candidate . $state$ === ChoreState . NONE
193+ ) {
189194 return candidate ;
190195 }
191196 }
192197 // Check in blockedChores
193198 for ( const candidate of blockedChores ) {
194- if ( candidate . $type$ === rule . blockingType && rule . match ( chore , candidate , container ) ) {
199+ if (
200+ candidate . $type$ === rule . blockingType &&
201+ rule . match ( chore , candidate , container ) &&
202+ candidate . $state$ === ChoreState . NONE
203+ ) {
195204 return candidate ;
196205 }
197206 }
198207
199208 // Check in runningChores
200209 for ( const candidate of runningChores ) {
201- if ( candidate . $type$ === rule . blockingType && rule . match ( chore , candidate , container ) ) {
210+ if (
211+ candidate . $type$ === rule . blockingType &&
212+ rule . match ( chore , candidate , container ) &&
213+ candidate . $state$ !== ChoreState . FAILED
214+ ) {
202215 return candidate ;
203216 }
204217 }
@@ -236,7 +249,11 @@ export function findBlockingChoreForVisible(
236249 }
237250
238251 for ( const candidate of runningChores ) {
239- if ( candidate . $type$ === rule . blockingType && rule . match ( chore , candidate , container ) ) {
252+ if (
253+ candidate . $type$ === rule . blockingType &&
254+ rule . match ( chore , candidate , container ) &&
255+ candidate . $state$ !== ChoreState . FAILED
256+ ) {
240257 return candidate ;
241258 }
242259 }
0 commit comments