Skip to content

Conversation

@vipero07
Copy link
Contributor

@vipero07 vipero07 commented Sep 17, 2025

It is currently possible for a chunk to import chunks that import itself. I'm not exactly sure where this occurs or why as I can't reproduce it in a simple repository, but a simple fix is to prevent importing already visited chunks.

This addresses #14444


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.

It is currently possible for a chunk to import chunks that import
itself. I'm not exactly sure where this occurs or why as I can't
reproduce it in a simple repository, but a simple fix is to prevent
importing already visited chunks.
@changeset-bot
Copy link

changeset-bot bot commented Sep 17, 2025

🦋 Changeset detected

Latest commit: 5dacc73

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 Patch

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

@vipero07
Copy link
Contributor Author

vipero07 commented Sep 17, 2025

This doesn't address why remote functions are being chunked oddly, it does however, speed up the build for any chunks that reference a previous referenced chunk. Which is to say, aside from not doom looping, this also doesn't reprocess chunks when other chunks converge on them. E.G.

flowchart
chunks --> chunk1
chunks --> chunk2
chunks --> chunk3

chunk1 --> chunk4
chunk2 --> chunk4
chunk3 --> chunk4

chunk4 --> chunk5
Loading

Without the PR chunk4 and chunk5 will be processed three times.

This also bails out when chunks reference eachother in a loop allowing the build to finish.

flowchart LR
chunk1 --> chunk2
chunk2 --> chunk3
chunk3 --> chunk4
chunk4 --> chunk1
Loading

Copy link
Member

@dummdidumm dummdidumm left a comment

Choose a reason for hiding this comment

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

thank you, this is a good fix regardless of the underlying issue!

@dummdidumm dummdidumm merged commit d4680a0 into sveltejs:main Sep 17, 2025
16 of 18 checks passed
@github-actions github-actions bot mentioned this pull request Sep 17, 2025
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 function build issues sveltekit @ 2.39.0 and up (tested up to and including 2.42.0)

2 participants