-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: use validated args in batch resolver #15114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 53335f6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this 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?)
b5b338c to
53335f6
Compare
|
Hi @teemingc, While writing the test I came across another bug. Current fix works fine for this is because I have updated the kit/packages/kit/src/runtime/app/server/remote/query.js Lines 199 to 211 in b5b338c
but not here kit/packages/kit/src/runtime/app/server/remote/query.js Lines 151 to 163 in 7237e8d
and because of this it is using the old returned function without validated args when batch functions are evaluated for kit/packages/kit/src/runtime/server/remote.js Lines 76 to 82 in 7237e8d
I have made the necessary changes and added test cases as well. |
fixes #15112
The PR includes following
run_remote_batch_functionwhich returns validated args along with resolver function, same as run_remote_function but with different return value.run_remote_batch_functionfunction 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:
Tests
pnpm testand lint the project withpnpm lintandpnpm checkChangesets
pnpm changesetand following the prompts. Changesets that add features should beminorand those that fix bugs should bepatch. Please prefix changeset messages withfeat:,fix:, orchore:.Edits