Skip to content

v4: hydration doesn't restore a static value that changes on the browser #8683

Closed
@gtm-nayan

Description

@gtm-nayan

Describe the bug

I'm guessing this is related to #7426.

Two SvelteKit tests started failing with version 4 as reported by ecosystem-ci, both of them were using the BROWSER variable from esm-env to display different content on the browser than on the server.

The compiler perceives the condition variable to be static and the generated code doesn't attempt to restore the html to the actual value at that moment.

Reproduction

https://github.com/sveltejs/svelte/tree/v4-hydration-bug

git clone https://github.com/sveltejs/svelte/tree/v4-hydration-bug
cd svelte/packages/playground
pnpm i
pnpm dev

Go to localhost:10001

Logs

None

System Info

n/a

Severity

blocking an upgrade

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions