Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught error: ServiceWorker controller not found! #133

Open
wgemm opened this issue May 7, 2024 · 14 comments
Open

Uncaught error: ServiceWorker controller not found! #133

wgemm opened this issue May 7, 2024 · 14 comments

Comments

@wgemm
Copy link

wgemm commented May 7, 2024

I am unsure if I am correct here or if the bug should go to posit-dev/shinylive.

My exported webassembly runs fine served localy with "python -m http.server ..." with Firefox, Chrome and Edge.
When served with a server over https from a Webspace it runs fine with Firefox, but not with Edge and Chrome.
I get the following error in Chrome:
image001

Any ideas?

Wolfram

@wch wch transferred this issue from posit-dev/py-shinylive May 7, 2024
@wch
Copy link
Collaborator

wch commented May 7, 2024

I've moved this issue to posit-dev/shinylive.

What is a Webspace?

@wgemm
Copy link
Author

wgemm commented May 8, 2024

A vserver at IONOS with a temporary domain using HTTPS.

@wch
Copy link
Collaborator

wch commented May 8, 2024

If you look in the JS console, does it say this somewhere?

Service Worker registered               load-shinylive-sw.js:37
image

That file sets up navigator.serviceWorker.controller:
https://github.com/posit-dev/shinylive/blob/b8911aefe89477c09d0014cf1fc94263a609195c/src/load-shinylive-sw.ts#L37-L52

And then this code checks for that object (and is where you are getting the error):

if (!navigator.serviceWorker.controller) {
throw new Error("ServiceWorker controller was not found!");
}

@wgemm
Copy link
Author

wgemm commented May 9, 2024

I get this:
grafik
May be the the preceding error is the problem. How can I give you more details about this.

Sorry I am very limited with my JS know how. That's why I use shiny for python :-)

@wch
Copy link
Collaborator

wch commented May 9, 2024

That's surprising to me. It sounds like load-serviceworker-sw.js is not able to load shinylive-sw.js here:

const serviceWorkerPath = serviceWorkerDir + "/shinylive-sw.js";
// Start the service worker as soon as possible, to maximize the
// resources it will be able to cache on the first run.
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register(serviceWorkerPath, { type: "module" })
.then(() => console.log("Service Worker registered"))
.catch(() => console.log("Service Worker registration failed"));

Here is the documentation for a 428 response code:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/428

Is the application deployed somewhere where I could access it?

@wgemm
Copy link
Author

wgemm commented May 11, 2024

I sent you an email with the URL

@wch
Copy link
Collaborator

wch commented May 14, 2024

Hi @wgemm, I don't think I've received the email. Can you send it to [email protected]?

@wgemm
Copy link
Author

wgemm commented May 22, 2024

I have sent the URL. I hope you received it.

@wch
Copy link
Collaborator

wch commented May 22, 2024

Thanks, I did receive it -- it had gone to my spam folder.

I've tried using the Chrome debugging tools to figure out what is going on, but for some reason it's not logging the full HTTP request and response. For example, here's the information for load-shinylive-sw.js, which does load properly:

image

And here is the information for shinylive-sw.js, which is the one that fails to load in Chrome with 428 status code (but it works in other browsers):

image

Notice that it's not showing the full Request Headers. When I try to look at the Preview panel, I see this:

image

For reference, this is what the request looks like in Safari:
image

I'm really not sure what the problem is and without that request header information, I don't know what Chrome is sending to the server that is different from Firefox and Safari.

I suspect there's some interaction between Chrome and your server at Plesk such that Chrome is making the request without some header that your server wants to see, but we would need to see the request header in order to compare it to Safari and Firefox to figure out what is different.

@noecochetel
Copy link

Hi,

I have a similar issue here: "Error: ServiceWorker controller was not found!", however, it can work depending on the app location within my website.

I have 2 directories: Public and Private (navigating to pages pointing to the Private directory requires authentication).

  • If the app is in the Public directory, it works fine.
  • If the app is in the Private directory, after authentication, it only works on Firefox/Safari and gives me the error code on Chrome.

Did you find any solution @wgemm ?

Thank you.

@davipatti
Copy link

Hello, I'm also getting a `ServiceWorker controller was not found!" error on a shinylive app requiring authentication and am interested if a solution exists!

@wgemm
Copy link
Author

wgemm commented Sep 20, 2024

Hi,

I have a similar issue here: "Error: ServiceWorker controller was not found!", however, it can work depending on the app location within my website.

I have 2 directories: Public and Private (navigating to pages pointing to the Private directory requires authentication).

* If the app is in the Public directory, it works fine.

* If the app is in the Private directory, after authentication, it only works on Firefox/Safari and gives me the error code on Chrome.

Did you find any solution @wgemm ?

Thank you.

No I didn't find a solution. Sorry.

@nshobert
Copy link

nshobert commented Oct 5, 2024

I have the same problem. Edge and Chrome browsers render the Shinylive editor temporarily and attempt to load the viewer. After a few seconds, the editor/viewer block collapses into a gray line and the console shows exactly the same Serviceworker controller not found! errors.

I just tried it in Firefox and it works. What a relief, though it would be nice to work in my familiar browser.

I am new to web development things so I don't know how to fix the Edge and Chrome issue, but wanted to add my experience to the thread in case it's helpful.

@vatulya
Copy link

vatulya commented Nov 14, 2024

I have the same issue with Edge and Chrome but not Firefox:

Image

And in this instance, too, I cannot read response headers from the failed service-worker fetch attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants