Skip to content

iOS 11.3.x and ngsw-worker.js Safari hangs on image upload #1909

Closed

Description

@Robinyo

Version info

Angular: 5.0.3

Angular Service Worker: 5.2.10

Firebase: 4.13.1

AngularFire: 5.0.0-rc.6

Ionic: 3.9.2

How to reproduce these conditions

When running my PWA in Safari on iOS 11.3.x, if I try to upload a file to Firebase Storage I see the following error in my Sentry console:

{code_: storage/unknown, message_: Firebase Storage: An unknown error occur…, name_: FirebaseError, serverResponse_: Multipart body does not contain 2 or 3 p…}

See:

Expected behaviour

I should be able to use Firebase Storage and an Angular Service Worker.

Actual behavior

I have to work around the issue, as follows

platformBrowserDynamic().bootstrapModule(AppModule).then((moduleRef) => {

  StaticInjectorService.setInjector(moduleRef.injector);

  const isSafari = () => {
    return navigator.userAgent.indexOf('Safari') !== -1;
  };

  if (isSafari()) {

    // https://github.com/angular/angular/issues/23244
    console.log('Service Worker not registered');

  } else {

    // https://stackoverflow.com/questions/48723206/angular-5-service-worker-not-working
    // Seems to be a problem in registering service worker in module where also importing AngularFire2
    if ('serviceWorker' in navigator && ENV.production) {
      navigator.serviceWorker.register('/ngsw-worker.js');
      console.log('Service Worker registered');
    }

  }

}).catch(error => console.log(error));

craft-beer-review

Activity

  1. mtschauer commented on Feb 19, 2019

    @mtschauer

    I'm having this issue as well. Thank you for documenting it so well. Do you know if StaticInjectorService is specific to Ionic? I don't see how to implement in plan AngularFire. Thanks!

  2. BluebambooSRL commented on Jul 21, 2019

    @BluebambooSRL

    I have the same issue... :(

  3. jek-bao-choo commented on Aug 3, 2019

    @jek-bao-choo
    Contributor

    Same issue

  4. jek-bao-choo commented on Aug 3, 2019

    @jek-bao-choo
    Contributor

    I have the same issue... :(

    Did you try @Robinyo's solution?

  5. vandres commented on Jul 3, 2020

    @vandres

    Can reproduce this on iOS12, iOS13 seems to work

  6. jamesdaniels commented on Nov 18, 2020

    @jamesdaniels
    Contributor

    ngsw registration was blocked by zone issues, most of those should be addressed now. going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions