qwik icon indicating copy to clipboard operation
qwik copied to clipboard

[🐞] Application stops working when server$ fails, even when network returns

Open genki opened this issue 1 year ago • 7 comments

Which component is affected?

Qwik Runtime

Describe the bug

I am trying to make a qwik app that can work even while the network is offline. I expected the server$ is not working if the network is offline. But not expected once the network went offline, the app never to be recovered even if the network is recovered again.

https://github.com/QwikDev/qwik/assets/4876/635a91ed-b75a-4688-a649-10d100759327

Relating with https://github.com/QwikDev/qwik-evolution/issues/105

Expected behaviour

The execution of the server$ would fail while network is offline, but it becomes online, then the execution of the server$ is succeeded. In the preview mode, it works same as in the dev mode.

Reproduction

https://github.com/genki/qwik-test/tree/offline_recovery_test

Steps to reproduce

Please git clone the repo above and

pnpm i
pnpm run dev

to visit the page on the browser.

Then,

  1. Click the links "Top" and "Demo" at the footer to check if the navigation is working.
  2. By using the dev tools, change the network status to "offline".
  3. Confirm the navigation would fail to move to the "Top" that is using the server$ and see the errors in the console.
  4. Change the network status to "no throttling" to recover the network.
  5. Click the "Top" link and confirm the navigation is still not working even if the network is online.

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M2
    Memory: 145.81 MB / 24.00 GB
    Shell: 3.6.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.12.1 - /opt/homebrew/opt/node@20/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.5.0 - /opt/homebrew/opt/node@20/bin/npm
    pnpm: 9.4.0 - ~/Library/pnpm/pnpm
    bun: 1.1.3 - ~/.bun/bin/bun
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 17.5
  npmPackages:
    @builder.io/qwik: file:../../clone/qwik/packages/qwik/dist => 1.5.6-dev20240709001810 
    @builder.io/qwik-city: file:../../clone/qwik/packages/qwik-city => 1.5.6 
    typescript: 5.1.6 => 5.1.6 
    undici: 5.22.1 => 5.22.1 
    vite: 4.4.0 => 4.4.0

Additional Information

No response

genki avatar Jul 09 '24 06:07 genki

If you remove the call of server$ from the "Top" page, the navigation is stay working even if go offline and of course after it is back. Maybe the fail of the dynamic import in the qwikloader crushes something.

genki avatar Jul 09 '24 07:07 genki

Hi, can you simulate this behaviour with an old version like 1.3.2 pls? Is this appending in preview mode?

gioboa avatar Jul 09 '24 07:07 gioboa

@gioboa In the preview mode, it happened that the "Demo" label getting multiplied per clicking "Top" link while the network is offline.

https://github.com/QwikDev/qwik/assets/4876/a496b4c8-0a5a-4894-bca8-e9c43c105aff

But the navigation has been recovered after the network is back online.

I will try to test with the qwik-1.3.2

genki avatar Jul 09 '24 07:07 genki

@gioboa I have tested with the qwik-1.3.2 (dev & preview), all behaviours were exactly same.

genki avatar Jul 09 '24 07:07 genki

Thanks for your tests. Can you add the expected behaviour in the description pls?

gioboa avatar Jul 09 '24 08:07 gioboa

@gioboa Yes, I added.

genki avatar Jul 09 '24 08:07 genki

The one of the reasons of this issue may be which there's no error handling for this line. https://github.com/QwikDev/qwik/blob/281de9701ecae0affcf18447985646917a2ef373/packages/qwik-city/runtime/src/server-functions.ts#L388

genki avatar Jul 09 '24 21:07 genki