Skip to content

fix: don't override new current_batch#18170

Merged
Rich-Harris merged 5 commits into
mainfrom
new-batch-override-fix
May 6, 2026
Merged

fix: don't override new current_batch#18170
Rich-Harris merged 5 commits into
mainfrom
new-batch-override-fix

Conversation

@dummdidumm

Copy link
Copy Markdown
Member

This is a regression from #18117 - we moved this.#commit() higher up but that means that current_batch could be nulled out / overridden through batch.activate/deactivate / blocker runs inside #commit(). Therefore restore the previous value afterwards. No changest because #18117 is not released yet.
Fixes the other part of the failing SvelteKit query.live test.

This is a regression from #18117 - we moved `this.#commit()` higher up but that means that `current_batch` could be nulled out / overridden through `batch.activate/deactivate` / blocker runs inside `#commit()`. Therefore restore the previous value afterwards.
No changest because #18117 is not released yet.
@changeset-bot

changeset-bot Bot commented May 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 7462194

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@svelte-docs-bot

Copy link
Copy Markdown

@github-actions

github-actions Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor

Playground

pnpm add https://pkg.pr.new/svelte@18170

@Rich-Harris

Copy link
Copy Markdown
Member

So here's something rather odd: the test passes, but it doesn't work in the playground (or locally, in the sandbox). I can't for the life of me figure out why.

@dummdidumm

dummdidumm commented May 6, 2026

Copy link
Copy Markdown
Member Author

Nice find! Turns out the logic in #18131 was also flawed, because it is a false positive in the test case in the playground:

  1. initial batch created
  2. batch gets an entry in the pending map because of the async work within the inner boundary
  3. microtask of Batch.schedule now resolves, thinking "oh there's pending work, there must've been a flushSync already, I'll bail"
  4. noone flushes it, stale UI. Didn't show in the test because we call flushSync() before calling test() - when not doing that (which I adjusted the test to) it shows in the test aswell

@Rich-Harris

Copy link
Copy Markdown
Member

Tried to leave a review comment but github is so completely broken that it doesn't work, so I guess I'll just leave a screenshot of a review comment instead? We all need to move off this joke of a platform yesterday

image

@Rich-Harris Rich-Harris merged commit 5e05457 into main May 6, 2026
21 checks passed
@Rich-Harris Rich-Harris deleted the new-batch-override-fix branch May 6, 2026 20:02
dummdidumm added a commit that referenced this pull request May 7, 2026
Fixes a regression of #18170 (not released yet therefore no changeset).
`current_batch` is nulled out if the `#commit` rebases other branches,
and that can lead to nullpointers down the line.

No test right now but it's part of getting the failing SvelteKit test
passing.
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.

2 participants