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

Commit

Permalink
better error: show a warning/error for unserializable server-preloade…
Browse files Browse the repository at this point in the history
…d data that can't be transmitted to the client
  • Loading branch information
babichjacob committed Jul 5, 2020
1 parent f3e9fc4 commit 427a6bc
Showing 1 changed file with 4 additions and 1 deletion.
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 => {
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

0 comments on commit 427a6bc

Please sign in to comment.