Skip to content

Page subscribe only works once after introducing $app/state #13200

Closed
@ciscoheat

Description

@ciscoheat

Describe the bug

When the $app/state module was added, a regression happened in $app/stores, breaking subscribing to the old page store there. This is the gist:

import { page } from '$app/stores';
page.subscribe((page) => console.log('Page update'));

This only works once if you have a callback on use:enhance and submits a form. After submitting the form multiple times, the subscribe callback isn't triggered.

<form method="POST" use:enhance={() => {
  // If adding use:enhance without this callback, it works
  return async ({ result }) => {
    await applyAction(result);
  };
}}
>
  <button>Submit</button>
</form>

Reproduction

https://github.com/ciscoheat/apply-action-problem

Logs

No response

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 42.93 GB / 63.93 GB
  Binaries:
    Node: 22.8.0 - C:\Program Files\nodejs\node.EXE       
    Yarn: 1.22.22 - ~\AppData\Local\pnpm\yarn.CMD
    npm: 9.3.1 - C:\Program Files\nodejs\npm.CMD
    pnpm: 9.15.0 - ~\AppData\Local\pnpm\pnpm.CMD
    bun: 1.0.32 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.19041.4355
  npmPackages:
    @sveltejs/adapter-auto: ^3.3.1 => 3.3.1
    @sveltejs/kit: ^2.12.2 => 2.12.2
    @sveltejs/vite-plugin-svelte: ^5.0.3 => 5.0.3
    svelte: ^5.14.4 => 5.14.4
    vite: ^6.0.3 => 6.0.3

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions