Skip to content

TypeError: Can't access property "increment", batch is null #16596

@jrmajor

Description

@jrmajor

Describe the bug

In specific cases, involving async and remote functions (see reproduction), Svelte throws an error:

TypeError: Can't access property "increment", batch is null

Reproduction

https://stackblitz.com/edit/svelte-await-null-batch-repro?file=src%2Froutes%2F%2Bpage.svelte

Open the preview in new tab, so that you can see console errors. Click the „OK” button in any row, then click „Verify next one”.

Found a simpler reproduction that doesn't involve SvelteKit: https://svelte.dev/playground/bc31c16761ea4fabbaf8634c62d0698f?version=5.38.0.

Logs

Uncaught (in promise) TypeError: can't access property "increment", batch is null
    async_derived deriveds.js:139
    update_reaction runtime.js:287
    update_effect runtime.js:467
    create_effect effects.js:125
    async_effect effects.js:338
    async_derived deriveds.js:118
    $$body Form.svelte:11
    Form Form.svelte:94
    effect2 hmr.js:47
    update_reaction runtime.js:287
    update_effect runtime.js:467
    create_effect effects.js:125
    branch effects.js:377
    wrapper hmr.js:38
    update_reaction runtime.js:287
    update_effect runtime.js:467
    create_effect effects.js:125
    block effects.js:365
    wrapper hmr.js:28
    alternate +page.svelte:32
    add_svelte_meta context.js:49
    alternate +page.svelte:32
    alternate_effect if.js:115
    update_reaction runtime.js:287
    update_effect runtime.js:467
    create_effect effects.js:125
    branch effects.js:377
    update_branch if.js:115
    set_branch if.js:48
    _page +page.svelte:7
    if_block if.js:140
    update_reaction runtime.js:287
    update_effect runtime.js:467
    #traverse_effect_tree batch.js:305
    process batch.js:212
    flush_effects batch.js:561
    flush batch.js:381
    ensure batch.js:460
    dequeue batch.js:69
    enqueue batch.js:471
    ensure batch.js:454
    internal_set sources.js:182
    set sources.js:161
    on_click +page.svelte:9
    handle_event_propagation events.js:263

System Info

(StackBlitz container)

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:
  svelte: ^5.38 => 5.38.0

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions