Skip to content

Conversation

@Rishab49
Copy link

@Rishab49 Rishab49 commented Dec 30, 2025

fixes #15112

The PR includes following

  • Added a new function run_remote_batch_function which returns validated args along with resolver function, same as run_remote_function but with different return value.
  • Updated the logic of batch to use run_remote_batch_function function and use the validated args while calling the resolver function.

Please don't delete this checklist! 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
  • 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

  • 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

  • Please ensure that 'Allow edits from maintainers' is checked. PRs without this option may be closed.

@changeset-bot
Copy link

changeset-bot bot commented Dec 30, 2025

🦋 Changeset detected

Latest commit: 53335f6

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

const validated = await with_request_store(store, () => validate(arg));
return {
resolver: with_request_store(store, () => fn(validated)),
validated_args: validated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this function has the exact same logic as run_remote_function, can we deduplicate this and simply change the returned value of the original function? Refactoring the other usages should be as simple as accessing the resolver property.

Copy link
Member

@teemingc teemingc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The fix is good. Just needs a changeset, a bit of refactoring and a test. The test can be added to packages/kit/test/apps/async/test/test.js and can be similar to the issue reproduction. We'll just need to verify the argument type in the returned function (maybe by sending that data to the page and asserting the correct type value via Playwright?)

@Rishab49 Rishab49 force-pushed the query_batch_validated_args branch from b5b338c to 53335f6 Compare January 8, 2026 13:22
@svelte-docs-bot
Copy link

@Rishab49
Copy link
Author

Rishab49 commented Jan 8, 2026

Hi @teemingc,

While writing the test I came across another bug.

Current fix works fine for ssr but when we enable csr then again we get the same unvalidated args to the resolver function.

this is because I have updated the run_remote_function to run_remote_batch_function here

const result = await run_remote_batch_function(
event,
state,
false,
batched.args,
(array) => Promise.all(array.map(validate)),
fn
);
for (let i = 0; i < batched.resolvers.length; i++) {
try {
batched.resolvers[i].resolve(result.resolver(result.validated_args[i], i));
} catch (error) {

but not here

run: (args) => {
const { event, state } = get_request_store();
return run_remote_function(
event,
state,
false,
args,
(array) => Promise.all(array.map(validate)),
fn
);
}
};

and because of this it is using the old returned function without validated args when batch functions are evaluated for csr

const args = payloads.map((payload) => parse_remote_arg(payload, transport));
const get_result = await with_request_store({ event, state }, () => info.run(args));
const results = await Promise.all(
args.map(async (arg, i) => {
try {
return { type: 'result', data: get_result(arg, i) };
} catch (error) {

I have made the necessary changes and added test cases as well.

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.

query.batch returned function input type is mismatched

2 participants