Skip to content

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

@lbensaad

Description

@lbensaad

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions