Skip to content

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

@GrandSchtroumpf

Description

@GrandSchtroumpf

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions