QwikDev / astro

Qwik + Astro integration
216 stars 13 forks source link

[404] /qwik-prefetch-service-worker.js #55

Closed Hunnnn77 closed 10 months ago

Hunnnn77 commented 10 months ago

I'm running output: server in astro, i can't understand why this 404 message comes up in log? luckly, there's no problems running app realated this message.

"@builder.io/qwik": "^1.3.5"
"@qwikdev/astro": "^0.4.0"
"astro": "^4.1.2",

14:40:20 [200] / 4ms
14:40:20 [200] /api/0 0ms
14:40:20 [404] /qwik-prefetch-service-worker.js
thejackshelton commented 10 months ago

I'm running output: server in astro, i can't understand why this 404 message comes up in log? luckly, there's no problems running app realated this message.

"@builder.io/qwik": "^1.3.5"
"@qwikdev/astro": "^0.4.0"
"astro": "^4.1.2",

14:40:20 [200] / 4ms
14:40:20 [200] /api/0 0ms
14:40:20 [404] /qwik-prefetch-service-worker.js

This is because of the new speculative module fetching, it does not break any pre-existing behavior. Aware of the issue, and reached out to the Astro team on how to fix it, since we need the file in the public folder when the user uses dev mode.

PaulieScanlon commented 10 months ago

Hey @thejackshelton, i'm experiencing the same issue.

I see 404 on the service-worker locally, and an uncaught promise when i deploy.

Here's a minimal reproduction if it's helpful.

PaulieScanlon commented 10 months ago

@thejackshelton

Boom! i updated the following packages and this has fixed the problem!

Chalk another one up for "Action Jack" Shelton :)

    "@builder.io/qwik": "^1.3.5",
    "@qwikdev/astro": "^0.4.3",
    "astro": "^4.1.3",
thejackshelton commented 10 months ago

@thejackshelton

Boom! i updated the following packages and this has fixed the problem!

Chalk another one up for "Action Jack" Shelton :)

    "@builder.io/qwik": "^1.3.5",
    "@qwikdev/astro": "^0.4.3",
    "astro": "^4.1.3",

Awesome!

About this issue, the qwik-prefetch-service-worker.js should not be in dev mode, and so this is expected. I guess the question is how we can supress this error in the integration, if anyone could tackle it that'd be awesome.

Arsh from the Astro core team told me that this happens because the client requested the file.

TheElegantCoding commented 10 months ago

I have the same error with this version

{
    "@builder.io/qwik": "1.4.0",
    "@qwikdev/astro": "0.4.4",
    "astro": "4.2.1"
}

Reproduction Repo

thejackshelton commented 10 months ago

I have the same error with this version

{
    "@builder.io/qwik": "1.4.0",
    "@qwikdev/astro": "0.4.4",
    "astro": "4.2.1"
}

Reproduction Repo

Thanks for keeping us updated! You can ignore this error for now, the file shouldn't be in dev mode anyways.

thejackshelton commented 10 months ago

To update on this issue, here is my findings:

If we create a new @qwikdev/astro application, and run the dev server, then we do not get the 404 warning.

In our application tab, we can see that no service workers are registed.

image

We can also see that the prefetch service worker and bundle graph scripts are not used in dev mode

image

The interesting part, is when we build our application. A qwik-prefetch-service-worker.js script is created.

image

When we go back to dev mode, we can see that the service worker is active. It would appear that the service worker is activated in dev mode when it should not be.

As a result, we then see the 404 warning.

image

I have a hunch here, that the problem lies in the fact that Astro uses the same port for dev mode and preview behavior. If we run pnpm dev --port 5173 for example, we never get the 404 request, nor the service worker register.

In fact, if we go back to 4321, and we unregister the service worker that seems to be created from our build in chrome's application tab, then we do not get the 404 in our terminal.

So it seems that the service worker in preview, is not being cleared in dev mode.

https://github.com/thejackshelton/sw-bug-dev

here is the example application I played with.

thejackshelton commented 10 months ago

Fixed in 0.4.8. Closing!