Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client layout.js doesn't trigger error page #6026

Closed
iceghost opened this issue Aug 18, 2022 · 2 comments
Closed

Client layout.js doesn't trigger error page #6026

iceghost opened this issue Aug 18, 2022 · 2 comments

Comments

@iceghost
Copy link
Contributor

Describe the bug

When layout.js returns on the server but throws an error on the browser, the error page doesn't show up but the console logs an uncaught error.

(page.js works as expected)

Reproduction

https://stackblitz.com/edit/sveltekit-client-layout-load-error-repro

Step 1: scaffold a skeleton project
Step 2: create a layout.svelte and a layout.js with the following content:

import { browser } from '$app/env';
import { error } from '@sveltejs/kit';

export function load() {
  if (browser) {
    throw error(500, 'layout load went poof');
  }
}

Step 3: go to homepage and the error page doesn't show up

Logs

Browser console:

16:17:35.830 Uncaught (in promise) 
Object { name: "HttpError", stack: undefined, status: 500, message: "layout load went poof" }

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /bin/yarn
    npm: 7.17.0 - /bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.64 
    @sveltejs/kit: next => 1.0.0-next.420 
    svelte: ^3.44.0 => 3.49.0 
    vite: ^3.0.0 => 3.0.8

Severity

annoyance

Additional Information

I want to initialize an indexedDB in load, which returns null on the server and await the DB on the browser. indexedDB may not available so the promise may reject. I want to handle this with an error page, which is not possible with this issue.

@iceghost
Copy link
Contributor Author

Oops... I think I get it—the error page depends on the layout, so if the layout doesn't load, the error page can't too.

@iceghost
Copy link
Contributor Author

This could be fixed with #4582 (error page with a different layout), so i will close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant