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

[🐞] v2 Signal is not updated in async task #7296

Open
GrandSchtroumpf opened this issue Jan 29, 2025 · 1 comment
Open

[🐞] v2 Signal is not updated in async task #7296

GrandSchtroumpf opened this issue Jan 29, 2025 · 1 comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working

Comments

@GrandSchtroumpf
Copy link
Contributor

Which component is affected?

Qwik Runtime

Describe the bug

const counter = useSignal(0);
useVisibleTask$(async () => {
  await new Promise(res => setTimeout(res, 1000));
  counter.value = 10;
  await new Promise(res => setTimeout(res, 1000));
  counter.value = 100;
});
return <p>{counter.value}</p>;

In v1, I would see 0, 10, 100
In v2, I see 0, 100

Reproduction

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

Steps to reproduce

Run this code in v1

const counter = useSignal(0);
useVisibleTask$(async () => {
  await new Promise(res => setTimeout(res, 1000));
  counter.value = 10;
  await new Promise(res => setTimeout(res, 1000));
  counter.value = 100;
});
return <p>{counter.value}</p>;

see 0, 10, 100

Run migration script: pnpm qwik migrate-v2

Run code again:
see 0, 100

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (32) x64 AMD Ryzen 9 7950X3D 16-Core Processor
    Memory: 16.52 GB / 31.18 GB
  Binaries:
    Node: 22.8.0 - ~\.nvm\versions\node\v22.8.0\bin\node.EXE
    npm: 10.9.0 - ~\.nvm\versions\node\v22.8.0\bin\npm.CMD
    pnpm: 9.10.0 - ~\.nvm\versions\node\v22.8.0\bin\pnpm.CMD
  Browsers:
    Edge: Chromium (129.0.2792.65)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    typescript: 5.5.4 => 5.5.4
    undici: 6.19.0 => 6.19.0
    vite: 5.3.5 => 5.3.5

Additional Information

No response

@GrandSchtroumpf GrandSchtroumpf added STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working labels Jan 29, 2025
@wmertens
Copy link
Member

wmertens commented Jan 29, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
STATUS-1: needs triage New issue which needs to be triaged TYPE: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants