Skip to content

Commit 9e93dc0

Browse files
committed
chore(core): _run should not wait
1 parent ece184e commit 9e93dc0

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed
Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import { QError, qError } from '../shared/error/error';
21
import 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';
53
import type { ValueOrPromise } from '../shared/utils/types';
64
import { getInvokeContext } from '../use/use-core';
75
import { 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

Comments
 (0)