Skip to content

Remote form().for() shares instance cache between forms during SSR #16661

@cofl

Description

@cofl

Describe the bug

Remote form() functions return the same instance from their for() methods when not client-side rendering. All forms using the same key will initially use the form action for the first form to use the key.

The expected behavior is that each form function has its own instance cache (so for example, an updatePost and deletePost form could each refer to the same post.id). This is how for() seems to behave during CSR, but not during SSR, which affects environments where CSR or JavaScript are disabled.

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-qfi3gy8i

Inspecting the second form element reveals that it has the same action as the first form. Changing the value of csr in +page.js and refreshing corrects this.

Logs

System Info

From repro terminal:


  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:
    svelte: ^5.25.0 => 5.38.3

Severity

annoyance

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