-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Which component is affected?
Qwik Runtime
Describe the bug
When tracking a signal inside useTask$, e.g.:
export default component$(() => {
const text = useSignal('');
useTask$(async ({track}) => {
track(() => text.value);
...
});
...
}
I would expect that when the signal is assigned a new value, the UI refreshes before useTask$
blocks. That is, when we do:
text.value = "new value";
I'd expect UI elements that use text.value
to be updated before track()
makes useTask$
run and blocks rendering.
Otherwise, it is almost as if the assignment itself is blocked until useTask$
returns, while the expectation is that the assignment takes place first, and only then, because a new value was already assigned, does track()
wake up and runs useTask$
.
Reproduction
Steps to reproduce
In the playground I set up, type 3 characters into the text box. When 3 characters are typed, we assign them to text.value
. At this point, we'd expect <p>Text = {text.value}</p>
to be updated, and useTask$
to run (because it is tracking text.value
). But instead, useTask$
is called and blocks (for 5 seconds in my example), and only then the UI reacts to the change in text.value
.
System Info
System:
OS: Linux 5.10 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (4) x64 Intel(R) Core(TM) i5-10400H CPU @ 2.60GHz
Memory: 13.92 GB / 15.63 GB
Container: Yes
Shell: 6.21.00 - /bin/tcsh
Binaries:
Node: 21.2.0 - /usr/local/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 10.2.3 - /usr/local/bin/npm
pnpm: 10.6.2 - /usr/local/bin/pnpm
npmPackages:
@builder.io/qwik: ^1.12.1 => 1.12.1
@builder.io/qwik-city: ^1.12.1 => 1.12.1
typescript: 5.4.5 => 5.4.5
undici: ^7.4.0 => 7.4.0
vite: 5.3.5 => 5.3.5
Additional Information
No response