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

Service worker registration failed. Status code: 3 #96

Open
kpripper opened this issue Oct 22, 2024 · 3 comments
Open

Service worker registration failed. Status code: 3 #96

kpripper opened this issue Oct 22, 2024 · 3 comments

Comments

@kpripper
Copy link

I just installed the code and haven’t changed anything yet, just ran it.

PS D:\Code\Chrome\ext-kaz-ra> npm run dev

> ext-kaz-ra@0.0.0 dev
> vite

Port 5173 is in use, trying another one...

  VITE v4.5.5  ready in 664 ms

  ➜  Local:   http://localhost:5174/
  ➜  Network: use --host to expose
  ➜  press h to show help
The emitted file "img/logo-34.png" overwrites a previously emitted file of the same name.
The emitted file "img/logo-48.png" overwrites a previously emitted file of the same name.
The emitted file "img/logo-16.png" overwrites a previously emitted file of the same name.
The emitted file "img/logo-128.png" overwrites a previously emitted file of the same name.

When I click on the extension icon, I see:

Vite Dev Mode Cannot connect to the Vite Dev Server on http://localhost:5174/

Double-check that Vite is working and reload the extension.

This page will close when the extension reloads.

On the extension management page in the errors section, I see the following message:

Service worker registration failed. Status code: 3

In the code, "service-worker-loader.js" is highlighted in yellow.

"background": {
  "service_worker": "service-worker-loader.js",
  "type": "module"
}
@azamuddin
Copy link

@kpripper happened to me on latest version of Chrome, previously no issue. This even affect the production extension that I already published, I wonder if this is because of new Chrome update

@KrishEnacton
Copy link
Contributor

KrishEnacton commented Nov 6, 2024

Update your vite.config.ts and add server object like this way

import { defineConfig } from 'vite';
import { crx } from '@crxjs/vite-plugin';
import react from '@vitejs/plugin-react';
// @ts-ignore
import manifest from './src/manifest';

// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
  return {
    build: {
      emptyOutDir: true,
      outDir: 'build',
      minify: true,
      rollupOptions: {
        output: {
          chunkFileNames: 'assets/chunk-[hash].js',
        },
      },
      chunkSizeWarningLimit: 2000,
    },
    server: {
      port: 5173,
      strictPort: true,
      hmr: {
        port: 5173,
      },
    },
    plugins: [crx({ manifest }), react()],
  };
});

@kpripper
Copy link
Author

kpripper commented Nov 6, 2024

Thank you, this works. But why isn't this included out of the box? Is it impossible?

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

3 participants