Skip to content

fix: atomically replace route metadata during sync - #17096

Merged
elliott-with-the-longest-name-on-github merged 1 commit into
version-3from
triage/kit-17095-atomic-route-metadata
Sep 14, 2026
Merged

elliott-with-the-longest-name-on-github merged 1 commit into
version-3from
triage/kit-17095-atomic-route-metadata

Conversation

@svelte-triage-bot

Copy link
Copy Markdown
Contributor

Fixes #17095.

Concurrent syncs could read route_meta_data.json while another process had truncated it for a direct rewrite. This caused intermittent JSON.parse failures.

This change:

  • preserves route metadata while stale generated route files are cleaned
  • writes metadata to a UUID-named temporary file outside the walked types directory
  • atomically renames the complete file into place
  • cleans temporary files in a finally block
  • adds a deterministic regression test that reproduces the competing-reader parse failure

The unique temporary name avoids collisions, while its location prevents another concurrent sync's types cleanup from removing an in-progress write.

Verification:

  • focused regression test
  • complete write_types/index.spec.js suite (21 tests)
  • pnpm -F @sveltejs/kit test:unit (783 passed)
  • pnpm lint
  • pnpm check
  • pnpm -F @sveltejs/kit prepublishOnly
  • 50 rounds of 8 parallel svelte-kit sync processes (0 failures)

@pkg-svelte-dev

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from f87a22d:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/f87a22d80aea6de76eb77dd5cf4727efb9db300a

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/kit/pr/17096

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Sep 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f87a22d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@elliott-with-the-longest-name-on-github
elliott-with-the-longest-name-on-github marked this pull request as ready for review September 14, 2026 22:09
@elliott-with-the-longest-name-on-github
elliott-with-the-longest-name-on-github merged commit f8258ee into sveltejs:version-3 Sep 14, 2026
37 of 38 checks passed
Rich-Harris pushed a commit that referenced this pull request Oct 1, 2026
alternative to #17231 cc:
@Nic-Polumeyv

closes #17224
re-opens #17095

This PR reverts the code and test changes from #17096 

We should probably find a different fix for #17095

---

### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:

- [x] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it
solves.
- [ ] Ideally, include a test that fails without this PR but passes with
it.

### Tests

- [ ] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`

### Changesets

- [x] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.

### Edits

- [x] Please ensure that 'Allow edits from maintainers' is checked. PRs
without this option may be closed.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sync: concurrent runs can read a truncated route_meta_data.json (JSON.parse error)

1 participant