Skip to content

Commit 1ef14ba

Browse files
committed
feat: log a warning instead of throwing an error for server host mismatch error
1 parent f3404ff commit 1ef14ba

File tree

3 files changed

+17
-36
lines changed

3 files changed

+17
-36
lines changed

.changeset/shaggy-poems-appear.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@qwik.dev/core': patch
3+
---
4+
5+
feat: log a warning instead of throwing an error for server host mismatch error

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

+6-8
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ export const codeToText = (code: number, ...parts: any[]): string => {
5050
"Element must have 'q:container' attribute.", // 42
5151
'Unknown vnode type {{0}}.', // 43
5252
'Materialize error: missing element: {{0}} {{1}} {{2}}', // 44
53-
'SsrError: {{0}}', // 45
5453
'Cannot coerce a Signal, use `.value` instead', // 46
5554
'useComputedSignal$ QRL {{0}} {{1}} returned a Promise', // 47
5655
'ComputedSignal is read-only', // 48
@@ -121,13 +120,12 @@ export const enum QError {
121120
elementWithoutContainer = 42,
122121
invalidVNodeType = 43,
123122
materializeVNodeDataError = 44,
124-
serverHostMismatch = 45,
125-
cannotCoerceSignal = 46,
126-
computedNotSync = 47,
127-
computedReadOnly = 48,
128-
wrappedReadOnly = 49,
129-
promisesNotExpected = 50,
130-
unsafeAttr = 51,
123+
cannotCoerceSignal = 45,
124+
computedNotSync = 46,
125+
computedReadOnly = 47,
126+
wrappedReadOnly = 48,
127+
promisesNotExpected = 49,
128+
unsafeAttr = 50,
131129
}
132130

133131
export const qError = (code: number, errorMessageArgs: any[] = []): Error => {

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

+6-28
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ import { QScopedStyle } from './utils/markers';
115115
import { addComponentStylePrefix } from './utils/scoped-styles';
116116
import { type WrappedSignal, type ComputedSignal, triggerEffects } from '../signal/signal';
117117
import type { TargetType } from '../signal/store';
118-
import { QError, qError } from './error/error';
119118

120119
// Turn this on to get debug output of what the scheduler is doing.
121120
const DEBUG: boolean = false;
@@ -294,7 +293,7 @@ export const createScheduler = (
294293
}
295294
while (choreQueue.length) {
296295
const nextChore = choreQueue.shift()!;
297-
const order = choreComparator(nextChore, runUptoChore, rootVNode, false);
296+
const order = choreComparator(nextChore, runUptoChore, rootVNode);
298297
if (order === null) {
299298
continue;
300299
}
@@ -462,28 +461,10 @@ function vNodeAlreadyDeleted(chore: Chore): boolean {
462461
*
463462
* @param a - The first chore to compare
464463
* @param b - The second chore to compare
465-
* @param shouldThrowOnHostMismatch - Controls error behavior for mismatched hosts
466-
* @returns A number indicating the relative order of the chores, or null if invalid. A negative
467-
* number means `a` runs before `b`.
464+
* @returns A number indicating the relative order of the chores. A negative number means `a` runs
465+
* before `b`.
468466
*/
469-
function choreComparator(
470-
a: Chore,
471-
b: Chore,
472-
rootVNode: ElementVNode | null,
473-
shouldThrowOnHostMismatch: true
474-
): number;
475-
function choreComparator(
476-
a: Chore,
477-
b: Chore,
478-
rootVNode: ElementVNode | null,
479-
shouldThrowOnHostMismatch: false
480-
): number | null;
481-
function choreComparator(
482-
a: Chore,
483-
b: Chore,
484-
rootVNode: ElementVNode | null,
485-
shouldThrowOnHostMismatch: boolean
486-
): number | null {
467+
function choreComparator(a: Chore, b: Chore, rootVNode: ElementVNode | null): number {
487468
const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
488469
if (macroTypeDiff !== 0) {
489470
return macroTypeDiff;
@@ -511,11 +492,8 @@ function choreComparator(
511492
You are attempting to change a state that has already been streamed to the client.
512493
This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).
513494
Problematic Node: ${aHost.toString()}`;
514-
if (shouldThrowOnHostMismatch) {
515-
throw qError(QError.serverHostMismatch, [errorMessage]);
516-
}
517495
logWarn(errorMessage);
518-
return null;
496+
return 1;
519497
}
520498
}
521499

@@ -557,7 +535,7 @@ function sortedFindIndex(
557535
while (bottom < top) {
558536
const middle = bottom + ((top - bottom) >> 1);
559537
const midChore = sortedArray[middle];
560-
const comp = choreComparator(value, midChore, rootVNode, true);
538+
const comp = choreComparator(value, midChore, rootVNode);
561539
if (comp < 0) {
562540
top = middle;
563541
} else if (comp > 0) {

0 commit comments

Comments
 (0)