You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
snapshot() helper does not restore on reload when ssr is disabled #17476
When ssr is disabled, state captured with the new snapshot() helper from $app/navigation is not restored after a page reload. The value is persisted to sessionStorage (under sveltekit:navigation-snapshot) but restore is never called.
The deprecated export const snapshot restores correctly on the same kind of page, and the snapshot() helper restores correctly on reload when the page is server-rendered (covered by the existing persists function snapshots with transport support test).
added to packages/kit/test/apps/basics under the existing /no-ssr layout:
test('restores exported snapshots on reload when ssr is disabled',async({ page })=>{awaitpage.goto('/no-ssr/snapshot/export');awaitpage.locator('input').fill('reload value');awaitpage.reload();awaitexpect(page.locator('input')).toHaveValue('reload value');// passes});test('restores function snapshots on reload when ssr is disabled',async({ page })=>{awaitpage.goto('/no-ssr/snapshot/helper');awaitpage.locator('input').fill('reload value');awaitpage.reload();awaitexpect(page.locator('input')).toHaveValue('reload value');// fails: received ""});
Workaround: keep using the deprecated export const snapshot.
From instrumenting the client runtime: on reload with ssr = false, the helper's onMount registration runs while the initial client-side navigation is still in progress (started is false, is_navigating/updating are true), so get_idle_history_index() returns null and the helper skips restoring there. The restore_navigation_snapshot(current_history_index) call at the end of initialize also doesn't invoke the callback, even though the persisted entry for that history index is in sessionStorage. I haven't pinned down why the second path misses it.
Activity
fix: restore function snapshots on reload without SSR (sveltejs#17477)