Skip to content

fix: cleanup non render effects created inside block effects #13586

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

Closed
wants to merge 1 commit into from

Conversation

paoloricciuti
Copy link
Member

Svelte 5 rewrite

This closes #13573.

Needed note: i'm not familiar with the whole effects orchestration so this code is the result of debugging the cause + trying to fix the issue + debugging the bugs caused by the issue. This means there might be a far easier way to achieve the same thing that i missed. I tried to cleanup the code as much as possible but there might be a cleaner way to achieve the same thing (i will also try to look at this tomorrow with a fresh mind to see if i missed something stupid). In the meantime this could at least be used as a starting point to:

  1. understand the issue
  2. maybe have a better idea for the implementation

A small recap of the issue is: when updating effects children of BLOCK_EFFECT were never cleaned up. This usually it's not a problem because those are generally template effects that will either be handled by the block itself (with pause and resume) or cleaned up when the component unmounts. However if the user does something like the test that i've added they are creating an effect in the block which needs to be cleaned up. So my solution was to move the check to avoid cleaning up RENDER_EFFECT's inside the destroy_effect_children while also adding the logic to keep the linked list up to date. I've also had to add a force parameter because if we are coming from destroy_effect rather than update_effect we want to clean everything and i had to add a constant to differenciate between RENDER_EFFECT and PRE_EFFECT because otherwise PRE_EFFECTS would not be cleaned up (originally they were RENDER_EFFECTS.

I opted into still makingPRE_EFFECT's also a RENDER_EFFECT to avoid touching too much and i think it's probably fine like this.

Please note that the Svelte codebase is currently being rewritten for Svelte 5. Changes should target Svelte 5, which lives on the default branch (main).

If your PR concerns Svelte 4 (including updates to svelte.dev.docs), please ensure the base branch is svelte-4 and not main.

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
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Oct 12, 2024

🦋 Changeset detected

Latest commit: ff508a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte 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

@trueadm
Copy link
Contributor

trueadm commented Oct 14, 2024

Put up a simpler alternative #13600.

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.

{#await} breaks $effect cleanup
2 participants