Skip to content

fix: atomically replace route metadata during sync - #17096

Draft
svelte-triage-bot[bot] wants to merge 1 commit into
version-3from
triage/kit-17095-atomic-route-metadata
Draft

fix: atomically replace route metadata during sync#17096
svelte-triage-bot[bot] wants to merge 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

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)

0 participants