Skip to content

[🐞] V2: Bug when signal of useComputed$ is used in useTask$ or useVisibleTask$ #7213

Open
@fabian-hiller

Description

@fabian-hiller

Which component is affected?

Qwik Runtime

Describe the bug

When a useComputed$ signal is read in useVisibleTask$, the task is executed twice (or multiple times if multiple useComputed$ are used). Also, useComputed$ is unnecessarily re-executed afterwards.

Reproduction

https://stackblitz.com/edit/github-o2f6fj9n-meq2plo7?file=src%2Froutes%2Findex.tsx

Steps to reproduce

  1. Open StackBlitz link
  2. Open and clear browser console
  3. Reload Qwik App

Now you should see this in the console:

useVisibleTask$: Do stuff with text...
useVisibleTask$: Do stuff with text...
useComputed$: Computing initial text...

The expected output would be:

useVisibleTask$: Do stuff with text...

This is because useComputed$ should only run once on the sever and useVisibleTask$ should only run once in the browser. A similar bug exists when using useTask$.

System Info

-

Additional Information

No response

Metadata

Metadata

Assignees

Type

No type

Projects

  • Status

    In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions