fix: allow requested() in a command called from other server code - #17040
fix: allow requested() in a command called from other server code#17040kdelay wants to merge 1 commit into
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/b768d38b9d881f8ddffaf9fa0f8a828fba8c6c6fOpen in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
🦋 Changeset detectedLatest commit: b768d38 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: QUIET Plan: Advanced Run ID: 📒 Files selected for processing (4)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe command wrapper now passes copied request state with Merge Risk: ⚪ Minimal · up to Commands invoked from server code can now use requested() without throwing, while requests without client refresh state remain no-ops. The behavior is covered by targeted runtime tests and is ready to merge. 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
packages/kit/src/runtime/app/server/remote/command.jsESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. packages/kit/src/runtime/app/server/remote/command.spec.jsESLint skipped: the matched ESLint configuration already failed (missing-dependency). packages/kit/src/runtime/app/server/remote/requested.jsESLint skipped: the matched ESLint configuration already failed (missing-dependency). Comment |
Fixes #17035.
requested()throws as soon as a command runs outside a/_app/remote/...request, e.g. when a+server.jshandler calls it.is_in_remote_form_or_commandis set only by the remote endpoint, so "inside a command" now means "the request arrived at that endpoint". Before #15991 the command wrapper marked the context itself.The wrapper sets the flag again, the way
query.bindsetsis_in_remote_query. Such a request has no client-side cache to update, sorequested()yields nothing andrefreshAll()is a no-op rather than throwing.Testing
pnpm -F @sveltejs/kit test:unit— the first test in the newcommand.spec.jsfails without the runtime changepnpm lint,pnpm -F @sveltejs/kit check,prepublishOnlytest-asyncremote suite in dev mode