Skip to content

$state.is always returns false during ssr #11829

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

Closed
david-roeger opened this issue May 29, 2024 · 0 comments · Fixed by #11835
Closed

$state.is always returns false during ssr #11829

david-roeger opened this issue May 29, 2024 · 0 comments · Fixed by #11835
Assignees

Comments

@david-roeger
Copy link

Describe the bug

The $state.is rune will always return false if run on the server even when $state and object are the same.

e.g.

const obj = { "hi": 1 };
const a = $state(obj)

// this is true on the server but false on the client which seems correct
console.log(a === obj)

// this is false on the server but true on the client which seems wrong
console.log($state.is(a, obj))

I would expect $state.is to return true on the server if the $state and object are the same.

Reproduction

SvelteLab

See the logs in the server console:

a === obj: true
$state.is(a, obj): false
a === b: true
$state.is(a, b): false

In the browser

a === obj: false
$state.is(a, obj): true
a === b: true
$state.is(a, b): true

Logs

No response

System Info

System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.67 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.0.0 - ~/.nvm/versions/node/v22.0.0/bin/node
    npm: 10.5.1 - ~/.nvm/versions/node/v22.0.0/bin/npm
    pnpm: 9.1.1 - ~/.nvm/versions/node/v22.0.0/bin/pnpm
    bun: 1.1.9 - /opt/homebrew/bin/bun
    Watchman: 2024.04.22.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 125.0.6422.112
    Safari: 17.4.1
  npmPackages:
    svelte: 5.0.0-next.144 => 5.0.0-next.144

Severity

blocking an upgrade

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

Successfully merging a pull request may close this issue.

2 participants