Commit activity
Last 12 weeks · 172 commits
Community health
6 of 6 standards met
Recent PRs & issues
Alternative to #19240. Not quite ready yet — two tests are still failing, and I think there are further opportunities for simplification — but I think the overall idea makes sense. Essentially, any time a branch has expressions, we wrap the contents in a synthetic block, where means 'all the async dependencies have a value'. The problem this solves is most easily illustrated with this example: If and are written, and then is written while we're waiting for the initial , and the second batch resolves before the first, at present we will render before the expression is ready. With this change, we render initially, then update it to when the first batch resolves.
Describe the bug With , while one change is waiting on an and another change is processed, so is set, a dirty executes again on every read instead of once. A derived read N times runs N times, and one read inside another derived multiplies. In the reproduction below, runs 2,000 times for one click while the DOM ends up correct. teemingc's comment below shows that through a chain of deriveds the re-runs compound and can freeze the tab. The mechanism has come up before. This comment on #18624 describes it with SvelteKit's as the trigger, and #18355 is about the same retained dirtiness during overlapping batches, there as an infinite loop. Two things here are new: the trigger is plain Svelte (one pending plus an unrelated state change), and the amplification grew sharply in 5.46.3. Up to 5.46.1, didn't re-evaluate a derived when . Some redundant work already existed: runs 11 times in the reproduction, once per read plus one. #17362 (5.46.3) removed that condition. Now runs and then (runtime.js#L683-L692) before it consults (#L700). While , caches the value in but deliberately leaves the derived's status dirty (deriveds.js#L428-L436), so every read executes it again. A chain does the same: calls (runtime.js#L167-L169) and doesn't reset the status while time-travelling (#L176-L183). Restoring only the condition brings back to 1 but still runs 11 times, as in 5.46.1. #18988 fixed both paths when tested at 8a1046e. It was merged into , not , and that branch into #18880's, which is still open; the table below has and #18880's head. Reproduction Project setup (Vite 8.3.4, @sveltejs/vite-plugin-svelte 7.3.1, experimental.async) , where every promise is resolved by hand: Each step has to run in its own task: on one line becomes a single update. Paste one of these into the console after a fresh load: / (Chromium, dev server): In A, doesn't depend on , so it needn't run, and should run once. In B, the resolved change moves , so each runs once. Logs System Info Severity annoyance
Recent fixes
links the license badge to . GitHub resolves that relative to , so the badge opens , which does not exist. The license file is at the repository root. The link now points at the root with an absolute URL so it also works when the README is read from the npm package. Before submitting the PR, please make sure you do the following [ ] 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] Prefix your PR title with , , , or . [x] This message body should clearly illustrate what problems it solves. [ ] Ideally, include a test that fails without this PR but passes with it. [ ] If this PR changes code within , add a changeset (). Tests and linting [ ] Run the tests with and lint the project with
Repository: sveltejs/svelte. Description: web development for the rest of us Stars: 88725, Forks: 6063. Primary language: JavaScript. Languages: JavaScript (70.6%), Svelte (22.4%), TypeScript (5%), CSS (1.1%), HTML (0.8%). License: MIT. Homepage: https://svelte.dev Topics: compiler, template, ui. Latest release: svelte@5.57.3 (2w ago). Open PRs: 100, open issues: 1192. Last activity: 10m ago. Community health: 87%. Top contributors: Rich-Harris, dummdidumm, Conduitry, github-actions[bot], trueadm, tanhauhau, paoloricciuti, benmccann, PuruVJ, baseballyama and others.