Skip to content
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

Nested untracked cause effect to run #536

Closed
mykola-vrmchk opened this issue Mar 19, 2024 · 4 comments
Closed

Nested untracked cause effect to run #536

mykola-vrmchk opened this issue Mar 19, 2024 · 4 comments

Comments

@mykola-vrmchk
Copy link

mykola-vrmchk commented Mar 19, 2024

I run into a problem of infinite cycles in my project.
Here is a reproduction snippet

import { effect, signal, untracked } from '@preact/signals-core';
import { expect } from 'chai';

describe('Untracked', () => {
  it('Nested `untracked` does not cause effect to run', async () => {
    const thisSignal = signal({});
    let updateCount = 0;

    untracked(() => {
      effect(() => {
        untracked(() => {
          const _ = thisSignal.value;
          thisSignal.value = {};
          updateCount++;
        });
      });
    });

    expect(updateCount).to.eq(1);
  });
});

The code above will produce an error Error: Cycle detected, it happens because nested untracked causes effect to run.

I am wondering if this is expected behavior

@jviide
Copy link
Contributor

jviide commented Mar 19, 2024

This was recently fixed in #512 but a new version has not yet been released.

@mykola-vrmchk

This comment was marked as off-topic.

@JoviDeCroock
Copy link
Member

Closing as released and fixed

@mykola-vrmchk
Copy link
Author

@JoviDeCroock awesome, thanks

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

No branches or pull requests

3 participants