Skip to content

state_invalid_placement when using async & remote functions branches #16319

Closed as not planned
@ottomated

Description

@ottomated

Describe the bug

The following error prevents all usage of the async / remote function branches of svelte

[plugin:vite-plugin-svelte-module] node_modules/@sveltejs/kit/src/runtime/client/remote.svelte.js:124:18 `$state.raw(...)` can only be used as a variable declaration initializer or a class field
https://svelte.dev/e/state_invalid_placement
node_modules/@sveltejs/kit/src/runtime/client/remote.svelte.js:124:18
122 |      };
 123 |  
 124 |      this.#promise = $state.raw(this.#fn());
                                                  ^
 125 |    }
 126 |

Reproduction

REPL

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @sveltejs/kit: https://pkg.pr.new/sveltejs/kit/@sveltejs/kit@3b2a636 => 2.22.2 
    svelte: https://pkg.pr.new/svelte@async => 5.28.2

Severity

blocking all usage of svelte

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