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

Waiting for service worker #12

Open
erezsh opened this issue Jan 29, 2023 · 6 comments
Open

Waiting for service worker #12

erezsh opened this issue Jan 29, 2023 · 6 comments

Comments

@erezsh
Copy link

erezsh commented Jan 29, 2023

Interacting with the boilerplate extension after letting the service worker to become inactive, we are greeting with the aforementioned message, which doesn't go away until we close and open the page again -

image

image

I think the desired behavior would be to hide this message once the worker is done loading.

@NekitCorp
Copy link
Owner

NekitCorp commented Jan 30, 2023

This is the message from crxjs: crxjs/chrome-extension-tools#449

Follow the link to find out why this happens and what it affects. In short, this error only occurs during development and due to the fact that you turn off the development dev Vite server.

And so try just start the dev server:

npm run dev

Or you can build production version of extension (npm run build) and reload extension (in chrome://extensions).

@erezsh
Copy link
Author

erezsh commented Jan 30, 2023

This happens while the server is running.

The worker starts immediately after displaying that message, and reloading the page gets rid of the message. But I think the reload should be automatic?

@NekitCorp
Copy link
Owner

I don't quite understand what the problem is, could you send me the steps to reproduce and the expected behavior please? And also please tell me this problem is reproduced in a clean fork chrome-extension-svelte-typescript-boilerplate?

@NekitCorp
Copy link
Owner

NekitCorp commented Jan 30, 2023

And once again I repeat that this error occurs only during development. In production, this error will not occur. It seems to me that the case with disabling the service worker is quite rare (because, for example, chrome works in the backround mode even when the browser is closed and the service worker continues to work), so simply reopening the extension to solve this problem in development mode is enough. In general, after reopening, the extension will already know about restarting the server worker.

Screen Recording 2023-01-30 at 15 40 13

@erezsh
Copy link
Author

erezsh commented Jan 30, 2023

Yes, this happens with a clean fork.

Steps are simple:

  1. Run extension
  2. Wait for service worker to become idle (takes about a minute)
  3. Open options / popup, and get this message
  4. Opening options / popup again immediately after will work as expected.

I understand this only happens in dev mode.

Whether it's enough or not is, I suppose, subjective. But I think that if the boilerplate knows to show this error page, it shouldn't be that hard to just wait for the worker to be ready and reload? It would definitely be a nicer dev experience.

@NekitCorp
Copy link
Owner

NekitCorp commented Jan 30, 2023

Oh, thanks, i get what you mean. I agree, sounds like a nice dev experience. But unfortunately, I can’t influence this logic in this boilerplate. Because this is the package logic from https://github.com/crxjs/chrome-extension-tools.

I think you can bring this idea to this issue: crxjs/chrome-extension-tools#449.

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

2 participants