Skip to content

breaking: error when a client-requested single-flight mutation isn't respected by the server, allow the server to explicitly ignore refreshes - #16892

Merged
teemingc merged 10 commits into
version-3from
elliott/warn-missing-refreshes
Aug 26, 2026
Merged

breaking: error when a client-requested single-flight mutation isn't respected by the server, allow the server to explicitly ignore refreshes#16892
teemingc merged 10 commits into
version-3from
elliott/warn-missing-refreshes

Conversation

@elliott-with-the-longest-name-on-github

@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

closes #16839

Prior to the PR, client-requested single-flight mutations had a weird inconsistency. When calling requested(query, limit), queries that exceeded limit would be failed by the server -- the server would generate a failure response for each one of them and send it back to the client. However, if requested wasn't called at all, we would just do... nothing. Your queries would just not refresh and you wouldn't know about it unless you happened to notice.

In addition to the inconsistency, the design was silly. The error for a missed refresh is the same for every query. The client already knows which queries were requested. So the server doesn't need to send back information about them! The client can just diff its list of requested refreshes with the response!

This PR addresses the two issues:

  • Any client-requested updates that aren't honored by the server will produce errors. These errors will now be generated on the client.
  • The server can intentionally ignore refreshes (basically saying "this didn't change" or "you don't actually need to update") by calling ignore:
for (const { arg, query, ignore } of requested(query, 5)) {
  if (was_updated(arg)) {
    void query.refresh();
  } else {
    ignore();
  }
}

If you just want to ignore a query altogether, there's a similar shorthand: requested(...).ignoreAll().

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 21, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 025774c:

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

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

@changeset-bot

changeset-bot Bot commented Aug 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 025774c

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 Major

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

@svelte-docs-bot

Copy link
Copy Markdown

Comment thread packages/kit/src/runtime/client/remote-functions/shared.svelte.js
@elliott-with-the-longest-name-on-github elliott-with-the-longest-name-on-github changed the title feat: Warn in dev when the client requests refreshes that the server doesn't fulfill breaking: error when a client-requested single-flight mutation isn't respected by the server, allow the server to explicitly ignore refreshes Aug 22, 2026
@svelte-triage-bot

Copy link
Copy Markdown
Contributor

I investigated this failed test run and found that test/client.test.js:831:2 › remote function mutations › form reconnect updates targeted live query without reconnecting all live queries is flaky.

The primary test used a timing-sensitive server cleanup counter despite traces showing the form response and targeted reconnect succeeded; it is stabilized by asserting observable reconnect requests. The separate flaky batch retry arose from module-level todo state leaking across retries and is fixed by resetting that state before baseline assertions. I opened #16896 with a proposed fix.

Comment thread documentation/docs/20-core-concepts/60-remote-functions.md Outdated
Comment thread documentation/docs/20-core-concepts/60-remote-functions.md
@teemingc
teemingc merged commit 65673a4 into version-3 Aug 26, 2026
72 of 73 checks passed
@teemingc
teemingc deleted the elliott/warn-missing-refreshes branch August 26, 2026 18:11
Rich-Harris pushed a commit that referenced this pull request Aug 27, 2026
Fixes two pre-existing async e2e flakes exposed by the CI run for
#16892.

The form reconnect test previously polled a server-side iterator cleanup
counter. The failed traces show that the form response succeeded and the
targeted `get_count` connection restarted, but transport cleanup had not
updated the counter within the assertion window. Assert the observable
reconnect requests directly instead, including that `get_finite_count`
is not reconnected.

The serial batch tests also retained module-level todo mutations across
retries. Reset the todos before asserting the baseline state so reruns
are idempotent.

Failed workflow:
https://github.com/sveltejs/kit/actions/runs/32541364509

Verification:
- primary test: 100 dev repetitions and 100 build repetitions
- batch mutation sequence: 40 tests
- relevant dev tests with two workers: 120 tests
- relevant build tests: 60 tests
- `pnpm -F test-async check`
- formatting and diff checks

Co-authored-by: svelte-triage-bot <team@svelte.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.

Warn when a requested refresh is dropped

2 participants