1- import { QError , qError } from '../shared/error/error' ;
21import type { QRLInternal } from '../shared/qrl/qrl-class' ;
3- import { getChorePromise } from '../shared/scheduler' ;
4- import { ChoreType } from '../shared/util-chore-type' ;
2+ import { retryOnPromise } from '../shared/utils/promises' ;
53import type { ValueOrPromise } from '../shared/utils/types' ;
64import { getInvokeContext } from '../use/use-core' ;
75import { useLexicalScope } from '../use/use-lexical-scope.public' ;
8- import { getDomContainer } from './dom-container ' ;
6+ import { VNodeFlags } from './types ' ;
97
108/**
119 * This is called by qwik-loader to run a QRL. It has to be synchronous.
@@ -17,20 +15,11 @@ export const _run = (...args: unknown[]): ValueOrPromise<unknown> => {
1715 const [ runQrl ] = useLexicalScope < [ QRLInternal < ( ...args : unknown [ ] ) => unknown > ] > ( ) ;
1816 const context = getInvokeContext ( ) ;
1917 const hostElement = context . $hostElement$ ;
20-
21- if ( ! hostElement ) {
22- // silently ignore if there is no host element, the element might have been removed
23- return ;
18+ if ( hostElement ) {
19+ return retryOnPromise ( ( ) => {
20+ if ( ! ( hostElement . flags & VNodeFlags . Deleted ) ) {
21+ return runQrl ( ...args ) ;
22+ }
23+ } ) ;
2424 }
25-
26- const container = getDomContainer ( context . $element$ ! ) ;
27-
28- const scheduler = container . $scheduler$ ;
29- if ( ! scheduler ) {
30- throw qError ( QError . schedulerNotFound ) ;
31- }
32-
33- // We don't return anything, the scheduler is in charge now
34- const chore = scheduler ( ChoreType . RUN_QRL , hostElement , runQrl , args ) ;
35- return getChorePromise ( chore ) ;
3625} ;
0 commit comments