Skip to content

Commit 1bd1df9

Browse files
committed
feat(cursors): fix some promises cases
1 parent 233e581 commit 1bd1df9

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

packages/qwik/src/core/shared/cursor/cursor-walker.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { isPromise } from '../utils/promises';
3535
import type { ValueOrPromise } from '../utils/types';
3636
import { assertDefined } from '../error/assert';
3737
import type { Container } from '../types';
38+
import { VNodeFlags } from '../../client/types';
3839

3940
const DEBUG = false;
4041

@@ -142,6 +143,14 @@ export function walkCursor(cursor: Cursor, options: WalkOptions): void {
142143
continue;
143144
}
144145

146+
// Skip if the vNode is deleted
147+
if (currentVNode.flags & VNodeFlags.Deleted) {
148+
// Clear dirty bits and move to next node
149+
currentVNode.dirty &= ~ChoreBits.DIRTY_MASK;
150+
setCursorPosition(container, cursor, getNextVNode(currentVNode));
151+
continue;
152+
}
153+
145154
let result: ValueOrPromise<void> | undefined;
146155
try {
147156
// Execute chores in order
@@ -179,18 +188,17 @@ export function walkCursor(cursor: Cursor, options: WalkOptions): void {
179188
DEBUG && console.warn('walkCursor: blocking promise', currentVNode.toString());
180189
// Store promise on cursor and pause
181190
setVNodePromise(cursor, result);
182-
// pauseCursor(cursor, currentVNode);
183191

192+
const host = currentVNode;
184193
result
185194
.catch((error) => {
186195
setVNodePromise(cursor, null);
187-
container.handleError(error, currentVNode);
196+
container.handleError(error, host);
188197
})
189198
.finally(() => {
190199
setVNodePromise(cursor, null);
191200
triggerCursors();
192201
});
193-
return;
194202
}
195203
}
196204
finishWalk(container, cursor, isServer);

packages/qwik/src/core/shared/cursor/cursor.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,6 @@ export function isCursor(vNode: VNode): vNode is Cursor {
4646
return (vNode.flags & VNodeFlags.Cursor) !== 0;
4747
}
4848

49-
/**
50-
* Pauses a cursor at the given vNode position. Sets the cursor position for time-slicing or promise
51-
* waiting.
52-
*
53-
* @param cursor - The cursor (vNode with CURSOR flag set) to pause
54-
* @param vNode - The vNode position to pause at
55-
*/
56-
export function pauseCursor(container: Container, cursor: Cursor, vNode: VNode): void {
57-
setCursorPosition(container, cursor, vNode);
58-
}
59-
6049
/**
6150
* Checks if a cursor is complete (root vNode is clean). According to RFC section 3.2: "when a
6251
* cursor finally marks its root vNode clean, that means the entire subtree is clean."

0 commit comments

Comments
 (0)