Create-react-app: Service worker script errors if run in chrome extension

Created on 17 Sep 2017  路  5Comments  路  Source: facebook/create-react-app

Is this a bug report?

Bug

Can you also reproduce the problem with npm 4.x?

Unrelated

Which terms did you search for in User Guide?

chrome

Environment

  1. node -v: 8.5.0
  2. npm -v: 5.4.0
  3. yarn --version (if you use Yarn):
  4. npm ls react-scripts (if you haven鈥檛 ejected): 1.0.13

Then, specify:

  1. Operating system: Ubuntu 16.04
  2. Browser and version (if relevant): Chrome 61

Steps to Reproduce

  • Run compiled app as chrome extension

Expected Behavior

  • No errors in console

Actual Behavior

Uncaught (in promise) TypeError: Request scheme 'chrome-extension' is unsupported
    at service-worker.js:1
    at <anonymous>
question > PWA

Most helpful comment

This is what I'd expect if you attempt to register a service worker that intercepts requests for chrome-extension: URLs. The service worker can't respond to to those types of requests, and there's an error logged suggesting as much.

Chrome has its own approach to installing/caching the resources needed to display a Chrome Extension. Service workers don't fit into that picture.

The message in the console can be safely ignored (it's not going to affect your extension's functionality), and to prevent it from showing up in the future, you can modify your index.js to remove the registerServiceWorker() call.

There's also an unregister function that you could optionally add in to your index.js if you've deployed this publicly and want to "clean up" the noise from the previous non-functionality registration.

All 5 comments

/cc @jeffposnick

any chance this is caused by some extension. Can you reproduce this in anonymous mode?

This is what I'd expect if you attempt to register a service worker that intercepts requests for chrome-extension: URLs. The service worker can't respond to to those types of requests, and there's an error logged suggesting as much.

Chrome has its own approach to installing/caching the resources needed to display a Chrome Extension. Service workers don't fit into that picture.

The message in the console can be safely ignored (it's not going to affect your extension's functionality), and to prevent it from showing up in the future, you can modify your index.js to remove the registerServiceWorker() call.

There's also an unregister function that you could optionally add in to your index.js if you've deployed this publicly and want to "clean up" the noise from the previous non-functionality registration.

@jeffposnick can you post an example how the code call for the unregister look like? same problem using RCA to build an extension.

// Inside index.js:
import {unregister} from './registerServiceWorker';
unregister();
Was this page helpful?
0 / 5 - 0 ratings

Related issues

stopachka picture stopachka  路  3Comments

onelson picture onelson  路  3Comments

fson picture fson  路  3Comments

dualcnhq picture dualcnhq  路  3Comments

JimmyLv picture JimmyLv  路  3Comments