Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

better error: show a warning/error when server-preloaded data can't be transmitted to the client #1304

Merged
merged 1 commit into from
Aug 7, 2020
Merged
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: 4 additions & 1 deletion runtime/src/server/middleware/get_page_handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,10 @@ export function get_page_handler(
const { html, head, css } = App.render(props);

const serialized = {
preloaded: `[${preloaded.map(data => try_serialize(data)).join(',')}]`,
preloaded: `[${preloaded.map(data => try_serialize(data, err => {
benmccann marked this conversation as resolved.
Show resolved Hide resolved
console.error(`Failed to serialize preloaded data to transmit to the client at the /${segments.join('/')} route: ${err.message}`);
console.warn('The client will re-render over the server-rendered page fresh instead of continuing where it left off. See https://sapper.svelte.dev/docs#Return_value for more information');
})).join(',')}]`,
session: session && try_serialize(session, err => {
throw new Error(`Failed to serialize session data: ${err.message}`);
}),
Expand Down