angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.64k stars 2.2k forks source link

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

Closed Robinyo closed 3 years ago

Robinyo commented 5 years ago

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

mtschauer commented 5 years ago

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!

BluebambooSRL commented 4 years ago

I have the same issue... :(

jek-bao-choo commented 4 years ago

Same issue

jek-bao-choo commented 4 years ago

I have the same issue... :(

Did you try @Robinyo's solution?

vandres commented 4 years ago

Can reproduce this on iOS12, iOS13 seems to work

jamesdaniels commented 3 years ago

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