Skip to content

__data.json page invalidation returns corrupted JSON in some rare cases #15511

@MSDev201

Description

@MSDev201

Describe the bug

In some cases, specially on slower network devices (also happens simulating slow network in chrome dev tools), the page invalidation call to __data.json contains invalid json making JSON.parse fail.

Image `{"id":239,�"url":240,`

Reproduction

I've only experienced this issue on routes having a streamed promise from a load function.
This issue has been poping up in my sentry issues for almoast a year and kept happening about 10 to 20 times a day for various users. I could never reproduce the issue my self so i put it of as a user issue with their network. Today this exact issue happened to me in my local dev environment which implies it most likely is not a user network issue and made me open this bug report.

Logs

__Local error:__

VM26528:1 Uncaught (in promise) SyntaxError: Expected ',' or '}' after property value in JSON at position 57040 (line 1 column 57041)
    at JSON.parse (<anonymous>)
    at client.js?v=55e50156:2943:23


VM26529:1 Uncaught (in promise) SyntaxError: Expected double-quoted property name in JSON at position 11079 (line 1 column 11080)
    at JSON.parse (<anonymous>)
    at client.js?v=55e50156:2943:23


happening in the `function load_data(url, invalid)` function

__One of the errors reported in Sentry:__

SyntaxError
Unexpected token '', "�{"type":""... is not valid JSON

System Info

System:
    OS: Windows 11 10.0.26200
    CPU: (24) x64 13th Gen Intel(R) Core(TM) i7-13700KF
    Memory: 28.95 GB / 63.86 GB
  Binaries:
    Node: 22.17.1 - C:\nvm4w\nodejs\node.EXE
    npm: 10.9.2 - C:\nvm4w\nodejs\npm.CMD
  Browsers:
    Chrome: 145.0.7632.160
    Edge: Chromium (145.0.3800.82)
    Internet Explorer: 11.0.26100.7309
  npmPackages:
    @sveltejs/adapter-node: ^5.5.3 => 5.5.3
    @sveltejs/kit: ^2.53.0 => 2.53.0
    svelte: ^5.53.2 => 5.53.2
    vite: ^6.3.0 => 6.4.1

Severity

annoyance

Additional Information

I can't verify it reliably but it seems like its happening more often when more requests to the invalidation endpoint are being issued.

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