-
-
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
Conversation
🦋 Changeset detectedLatest commit: 2b5a398 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. |
|
Looks like there are some linting problems but otherwise this looks pretty good |
|
I've reworked this a little bit but I'm noticing some weirdness with how we're handling errors, so I'm going to come back to it tomorrow to polish it off. Thank you! |
551595d to
43c0f8b
Compare
elliott-with-the-longest-name-on-github
left a comment
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.
I'm giving this my stamp of "it's ready" but since I modified it a bunch, I'm going to have @Rich-Harris or @teemingc review before I merge it -- whenever we get their stamp we can merge!
|
I think we can simplify it a little #15215 |
|
We went with Rich's solution, but I gave you co-contributor credit on the merge commit. Thank you! |
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