qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[🐞] await nav() inside useTask$ not working

Open lbensaad opened this issue 1 year ago • 8 comments

Which component is affected?

Qwik Runtime

Describe the bug

when i use nav() with await it does not work, if i remove await it works!

Reproduction

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

Steps to reproduce

I used this test code in the routes/index.tsx of the demo

export default component$(() => {

  const nav = useNavigate();
  const visible = useSignal(false);
  useVisibleTask$(async () => {
    visible.value=true;
  });
  useTask$(async ({track})=>{
    track(visible);
    if(visible.value){
       await nav("/demo/flower/");
    }
  }
);

  return (....)

but it works if i remove the await keyword. it will also works if i put it with the await keyword inside useVisibleTask$,

System Info

System:
    OS: Linux 6.10 Ubuntu 24.04.1 LTS 24.04.1 LTS (Noble Numbat)
    CPU: (8) x64 Intel(R) Core(TM) i7-2670QM CPU @ 2.20GHz
    Memory: 8.71 GB / 15.60 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 21.6.2 - ~/.nvm/versions/node/v21.6.2/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v21.6.2/bin/npm
    pnpm: 9.12.0 - ~/.local/share/pnpm/pnpm
    bun: 1.0.3 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 129.1.70.117
    Chrome: 129.0.6668.58
  npmPackages:
    @builder.io/qwik: ^1.9.1 => 1.9.1 
    @builder.io/qwik-city: ^1.9.1 => 1.9.1 
    typescript: 5.4.5 => 5.4.5 
    undici: * => 6.20.1 
    vite: 5.3.5 => 5.3.5

Additional Information

No response

lbensaad avatar Oct 21 '24 23:10 lbensaad

this may be fixed in v2, we're releasing the alpha soonish

wmertens avatar Oct 22 '24 16:10 wmertens

Thanks, are there any docs about v2 and breaking changes to start preparing for it or testing it?

lbensaad avatar Oct 23 '24 07:10 lbensaad

Thanks, are there any docs about v2 and breaking changes to start preparing for it or testing it?

I started working on it. Breaking changes will be very minimal, for now, here are the 2 main ones:

  • useComputed doesn't accept async functions anymore
  • <button> can contain only phrasing content as per HTML5 spec so any non-phrasing content (e.g. div inside button) will be rejected (error)

The packages will also be renamed from @builder.io/qwik to @qwik.dev/core, @qwik.dev/city (or routing), etc. but there will be a script to change it for you.

ianlet avatar Oct 26 '24 18:10 ianlet

Great, thank you @ianlet, any ETA for v2?

lbensaad avatar Oct 27 '24 19:10 lbensaad

I tested with v2 codebase and it's not working

gioboa avatar Nov 27 '24 11:11 gioboa

I tested with the latest v2 release and nav is not working with await.

gioboa avatar Aug 31 '25 11:08 gioboa

thanks @gioboa , what about nav() without params to refresh the page, I think it is also not working form.

lbensaad avatar Aug 31 '25 13:08 lbensaad

@Varixo do we have a decision on this?

gioboa avatar Dec 01 '25 17:12 gioboa