Skip to content

fix: don't redirect in forks#14964

Closed
dummdidumm wants to merge 6 commits into
mainfrom
fork-redirect-fix
Closed

fix: don't redirect in forks#14964
dummdidumm wants to merge 6 commits into
mainfrom
fork-redirect-fix

Conversation

@dummdidumm

@dummdidumm dummdidumm commented Nov 21, 2025

Copy link
Copy Markdown
Member

This prevents a redirect that a remote function could do from doing a navigation in a fork. Leverages Svelte's new forking methods from sveltejs/svelte#17217 (no longer needs those, but having committed/discarded would be nice)

It's implemented by putting the context into fork, pulling it out on remote function invocation to check if we're in a fork (TODO what if you have it invoked elsewhere and you just await it in a fork context?), put that into a map, and pull it out of there when a redirect occurs to check if the remote function is only called in context of that fork, and if so instead of redirecting we tell the SvelteKit router that this new route will redirect elsewhere. In the future we could follow that redirect and run it in the fork, but this is good enough for now and ties nicely into the current SvelteKit router.

Fixes #14935


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:.

@changeset-bot

changeset-bot Bot commented Nov 21, 2025

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 65dab6c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

This prevents a redirect that a remote function could do from doing a navigation in a fork.

It's implemented by putting the context into fork, pulling it out on remote function invocation to check if we're in a fork, put that into a map, and pull it out of there when a redirect occurs to check if the remote function is only called in context of that fork, and if so instead of redirecting we tell the SvelteKit router that this new route will redirect elsewhere. In the future we could follow that redirect and run it in the fork, but this is good enough for now and ties nicely into the current SvelteKit router.

Fixes #14935
@dummdidumm
dummdidumm marked this pull request as ready for review April 3, 2026 20:14
Comment thread packages/kit/src/runtime/client/client.js Outdated
Comment thread packages/kit/src/runtime/client/remote-functions/shared.svelte.js Outdated
@svelte-docs-bot

Copy link
Copy Markdown

@dummdidumm dummdidumm added this to the 3.0 milestone Jul 4, 2026
@dummdidumm

Copy link
Copy Markdown
Member Author

did put this on the 3.0 milestone now - we should discuss this, see if we need to adjust Svelte's fork, and if so we bump the minimum required version of Svelte 5 for SvelteKit 3 to the version that has it.

@pkg-svelte-dev

pkg-svelte-dev Bot commented Jul 9, 2026

Copy link
Copy Markdown

Install the latest version of @sveltejs/kit from 65dab6c:

pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/65dab6c265cd2e188f7bea3f3cc8040bfddd71ce

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

@dummdidumm
dummdidumm changed the base branch from main to version-3 July 9, 2026 14:24
@dummdidumm
dummdidumm changed the base branch from version-3 to main July 9, 2026 14:41
@dummdidumm

Copy link
Copy Markdown
Member Author

Closing in favor of #16292 which is basically this against version-3

@dummdidumm dummdidumm closed this Jul 9, 2026
@dummdidumm
dummdidumm deleted the fork-redirect-fix branch July 9, 2026 14:41
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.

Remote functions: Prefetching prematurely tiggers redirect, disabling it subsequently

2 participants