Skip to content

Commit 41397e6

Browse files
committed
feat(cursors): fix apply journal
1 parent ac95674 commit 41397e6

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function executeFlushPhase(cursor: Cursor, container: Container): void {
2424

2525
function flushChanges(vNode: VNode): void {
2626
const journal = getCursorJournal(vNode);
27-
if (!journal) {
27+
if (!journal || journal.length === 0) {
2828
return;
2929
}
3030
for (const operation of journal) {
@@ -74,7 +74,7 @@ function flushChanges(vNode: VNode): void {
7474
}
7575
}
7676
}
77-
setCursorJournal(vNode, []);
77+
setCursorJournal(vNode, null);
7878
}
7979

8080
function executeAfterFlush(container: Container, cursor: Cursor): void {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ export function getCursorContainer(vNode: VNode): Container | null {
205205
* @param vNode - The vNode
206206
* @param journal - The journal to set
207207
*/
208-
export function setCursorJournal(vNode: VNode, journal: VNodeJournal): void {
208+
export function setCursorJournal(vNode: VNode, journal: VNodeJournal | null): void {
209209
const props = (vNode.props ||= {});
210210
props[CURSOR_JOURNAL_KEY] = journal;
211211
}

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
setCursorJournal,
2929
} from './cursor-props';
3030
import { ChoreBits } from '../vnode/enums/chore-bits.enum';
31-
import { getHighestPriorityCursor, removeCursorFromQueue } from './cursor-queue';
31+
import { addCursorToQueue, getHighestPriorityCursor, removeCursorFromQueue } from './cursor-queue';
3232
import { executeFlushPhase } from './cursor-flush';
3333
import { createNextTick } from '../platform/next-tick';
3434
import { isPromise } from '../utils/promises';
@@ -97,11 +97,6 @@ export function walkCursor(cursor: Cursor, options: WalkOptions): void {
9797
const isServer = isServerPlatform();
9898
const startTime = performance.now();
9999

100-
// Check if cursor is already complete
101-
if (!cursor.dirty) {
102-
return;
103-
}
104-
105100
// Check if cursor is blocked by a promise
106101
const blockingPromise = getVNodePromise(cursor);
107102
if (blockingPromise) {
@@ -111,6 +106,12 @@ export function walkCursor(cursor: Cursor, options: WalkOptions): void {
111106
const container = getCursorContainer(cursor);
112107
assertDefined(container, 'Cursor container not found');
113108

109+
// Check if cursor is already complete
110+
if (!cursor.dirty) {
111+
finishWalk(container, cursor, isServer);
112+
return;
113+
}
114+
114115
let journal = getCursorJournal(cursor);
115116
if (!journal) {
116117
journal = [];
@@ -188,6 +189,7 @@ export function walkCursor(cursor: Cursor, options: WalkOptions): void {
188189
DEBUG && console.warn('walkCursor: blocking promise', currentVNode.toString());
189190
// Store promise on cursor and pause
190191
setVNodePromise(cursor, result);
192+
removeCursorFromQueue(cursor);
191193

192194
const host = currentVNode;
193195
result
@@ -197,6 +199,7 @@ export function walkCursor(cursor: Cursor, options: WalkOptions): void {
197199
})
198200
.finally(() => {
199201
setVNodePromise(cursor, null);
202+
addCursorToQueue(container, cursor);
200203
triggerCursors();
201204
});
202205
}

packages/qwik/src/core/ssr/ssr-render-component.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const applyQwikComponentBody = (
3535
if (jsx.key !== null) {
3636
host.setProp(ELEMENT_KEY, jsx.key);
3737
}
38-
const componentChore = ssr.$scheduler$(ChoreType.COMPONENT, host, componentQrl, srcProps);
39-
return getChorePromise(componentChore);
38+
return executeComponent(ssr, host, host, componentQrl, srcProps);
39+
// const componentChore = ssr.$scheduler$(ChoreType.COMPONENT, host, componentQrl, srcProps);
40+
// return getChorePromise(componentChore);
4041
};

packages/qwik/src/server/ssr-render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const renderToStream = async (
8989

9090
await setServerPlatform(opts, resolvedManifest);
9191
await ssrContainer.render(jsx);
92-
await ssrContainer.$scheduler$(ChoreType.WAIT_FOR_QUEUE).$returnValue$;
92+
// await ssrContainer.$scheduler$(ChoreType.WAIT_FOR_QUEUE).$returnValue$;
9393

9494
// Flush remaining chunks in the buffer
9595
flush();

0 commit comments

Comments
 (0)