Skip to content

Incorrect classnames during SSR #937

@endigma

Description

@endigma

Describe the bug

During server rendering, the target div is rendered with class routes__1ry5ddd0, which has no corresponding styles. It hydrates to _1ry5ddd0, which has the correct styles.

The provided example is nothing but the SvelteKit starter (pnpm create svelte@latest) with the vite plugin and a basic style added. It can be easily observed by comparing the hydrated DOM with "view page source" etc. You can also observe the lack of styling using an addon like uBlock Origin or uMatrix or NoScript etc to block JS.

You can clone the repo, run pnpm install, pnpm dev to see the issue.

The most outwardly visible symptom is a FOUC, you may or may not be able to see it depending on your setup.

The reproduce conditions are a little complicated, so I've created a table to help. There may be other reproduce conditions I'm not aware of yet, but these work on the repo I provided.

Running Mode identifiers Reproduce?
vite dev "short" Yes
vite dev "debug" Yes
vite build && vite preview "short" Yes
vite build && vite preview "debug" No

Reproduction

https://github.com/endigma/vanilla-extract-ssr-bug

System Info

System:
    OS: Linux 6.0 Void
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 6.65 GB / 31.26 GB
    Container: Yes
    Shell: 3.5.1 - /usr/bin/fish
  Binaries:
    Node: 16.15.1 - ~/.asdf/shims/node
    Yarn: 1.22.18 - /usr/bin/yarn
    npm: 8.11.0 - ~/.asdf/shims/npm
  Browsers:
    Chromium: 107.0.5304.87
    Firefox: 107.0
  npmPackages:
    @vanilla-extract/css: ^1.9.2 => 1.9.2 
    @vanilla-extract/vite-plugin: ^3.7.0 => 3.7.0 
    vite: ^3.2.4 => 3.2.4

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions