Skip to content

Commit 6d4e1c9

Browse files
committed
throw on serializing function
1 parent af71080 commit 6d4e1c9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export const codeToText = (code: number, ...parts: any[]): string => {
5656
'WrappedSignal is read-only', // 48
5757
'Attribute value is unsafe for SSR', // 49
5858
'SerializerSymbol function returned rejected promise', // 50
59+
'Serialization Error: Cannot serialize function: {{0}}', // 51
5960
];
6061
let text = MAP[code] ?? '';
6162
if (parts.length) {
@@ -126,6 +127,7 @@ export const enum QError {
126127
wrappedReadOnly = 48,
127128
unsafeAttr = 49,
128129
serializerSymbolRejectedPromise = 50,
130+
serializeErrorCannotSerializeFunction = 51,
129131
}
130132

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

packages/qwik/src/core/shared/shared-serialization.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -973,9 +973,7 @@ async function serialize(serializationContext: SerializationContext): Promise<vo
973973
serializationContext.$renderSymbols$.add(qrl.$symbol$);
974974
output(TypeIds.Component, [qrl]);
975975
} else {
976-
// TODO this happens for inline components with render props like Resource
977-
console.error('Cannot serialize function (ignoring for now): ' + value.toString());
978-
output(TypeIds.Constant, Constants.Undefined);
976+
throw qError(QError.serializeErrorCannotSerializeFunction, [value.toString()]);
979977
}
980978
} else if (typeof value === 'number') {
981979
if (Number.isNaN(value)) {

0 commit comments

Comments
 (0)