Skip to content

[bug] page destroyed during hydration if a file fails to load #2699

@benmccann

Description

@benmccann

Describe the bug

The page from the reproduction loads during SSR and then fails during hydration during dev mode if you both have adblock on and are not using the new experimental.prebundleSvelteLibraries option (RobBrazier/svelte-awesome#775).

This particular example is kind of an edge case, but the outcome is really bad and I'm not so sure how rare it is more generally. Per Rich's point, sometimes things fail to load because you live in NYC and take the subway and lose connectivity going into a tunnel. That the entire page would be wiped out eventhough SSR succeeded is quite a bad outcome. If we wrapped the whole hydration in a try/catch maybe you'd at least see the server-rendered page. Or perhaps if we had error boundaries the developer could do something smarter

Reproduction

https://github.com/benmccann/500-import-failure

Logs

I get a message in the browser:

Failed to fetch dynamically imported module: http://localhost:3000/src/routes/index.svelte

Screenshot:

Screenshot from 2021-10-28 09-30-41

System Info

This fails on 1.0.0-next.138 and newer all the way up to master since that's when we turned on compilerOptions.hydratable: #2024

https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md#100-next138

Severity

blocking all usage of SvelteKit

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghelp wantedPRs welcomed. The implementation details are unlikely to cause debatep2-nice-to-haveSvelteKit cannot be used by a small number of people, quality of life improvements, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions