Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/surface-vnode-resume-failures.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@qwik.dev/core': patch
---

fix: surface a failed vnode-data resume — report it and unblock the `whenVNodeDataReady` waiters — instead of swallowing the error into a silent hang.
8 changes: 4 additions & 4 deletions packages/qwik/src/core/client/process-vnode-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getSegmentVNodeRefId,
} from '../shared/vnode-data-types';
import type { ElementVNode } from '../shared/vnode/element-vnode';
import { logError } from '../shared/utils/log';
import type { ContainerElement, QDocument } from './types';
import {
createYieldingIteratorState,
Expand Down Expand Up @@ -143,7 +144,7 @@ export const whenVNodeDataReady = <T>(
});
};

function enqueueProcessVNodeDataJob(
export function enqueueProcessVNodeDataJob(
qDocument: QDocument,
iterator: Generator<void, void, void>
): void {
Expand Down Expand Up @@ -177,9 +178,8 @@ function scheduleProcessVNodeData(qDocument: QDocument, state: ProcessVNodeDataS
},
(error) => {
state.$active$ = null;
qDocument.qVNodeDataReady = qDocument.qVNodeDataStarted = false;
qDocument.qVNodeDataState = undefined;
throw error;
logError(error);
markVNodeDataReady(qDocument);
}
);
scheduleYieldingIterator(state.$active$);
Expand Down
19 changes: 19 additions & 0 deletions packages/qwik/src/core/client/process-vnode-data.unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '../../testing/vdom-diff.unit-util';
import { VNodeDataSeparator, getSegmentVNodeRefId } from '../shared/vnode-data-types';
import { DomContainer, getDomContainer } from './dom-container';
import {
enqueueProcessVNodeDataJob,
findVDataSectionEnd,
processOutOfOrderSegmentVNodeData,
processVNodeData,
Expand Down Expand Up @@ -1067,6 +1068,24 @@ describe('processVnodeData', () => {
});
});

describe('vnode-data resume errors', () => {
it('a resume error unblocks whenVNodeDataReady instead of hanging silently', async () => {
const document = createDocument() as QDocument;

// Drive the vnode-data pipeline with a throwing iterator
enqueueProcessVNodeDataJob(
document,
(function* () {
yield;
throw new Error('resume boom');
})()
);

await whenVNodeDataReady(document, () => undefined);
expect(true).toBe(true);
});
});

describe('emitVNodeSeparators', () => {
it('should encode binary correctly', () => {
expect(emitVNodeSeparators(0, 1)).toBe(VNodeDataSeparator.ADVANCE_1_CH);
Expand Down
Loading