diff --git a/runtime/src/server/middleware/get_page_handler.ts b/runtime/src/server/middleware/get_page_handler.ts index c0a39cc..5d9f118 100644 --- a/runtime/src/server/middleware/get_page_handler.ts +++ b/runtime/src/server/middleware/get_page_handler.ts @@ -225,7 +225,7 @@ export function get_page_handler( props[`level${l++}`] = { component: part.component, - props: preloaded[i + 1], + props: preloaded[i + 1] || {}, segment: segments[i] }; } diff --git a/test/apps/preloading/src/routes/preload-nothing/index.svelte b/test/apps/preloading/src/routes/preload-nothing/index.svelte new file mode 100644 index 0000000..6268767 --- /dev/null +++ b/test/apps/preloading/src/routes/preload-nothing/index.svelte @@ -0,0 +1,5 @@ + + +

Page loaded

diff --git a/test/apps/preloading/test.ts b/test/apps/preloading/test.ts index d30a8d1..97f68b7 100644 --- a/test/apps/preloading/test.ts +++ b/test/apps/preloading/test.ts @@ -37,6 +37,15 @@ describe('preloading', function() { assert.equal(await title(), 'true'); }); + it('prevent crash if preload return nothing', async () => { + await page.goto(`${base}/preload-nothing`); + + await start(); + await wait(50); + + assert.equal(await title(), 'Page loaded'); + }); + it('bails on custom classes returned from preload', async () => { await page.goto(`${base}/preload-values/custom-class`);