Skip to content

Use of XHR prevents Storage upload in Service Workers #902

@GabiAxel

Description

@GabiAxel

[REQUIRED] Describe your environment

  • Operating System version: MacOS 10.12.6, Chrome 66.0.3359.181
  • Firebase SDK version: 5.0.4
  • Firebase Product: Storage

[REQUIRED] Describe the problem

Storage upload functionality uses XhrIo, which uses XHR. XHR is not available in Service Workers, so it's not possible to upload files to storage in Service Workers with the current JS SDK.

I propose replacing the use of XHR with Fetch (or Websockets?) or at least support both and provide a way to switch to Fetch.

Use case: resumable upload of large files over slow networks which will not break when the user navigates away or closes the browser window.

Steps to reproduce:

In a Service Worker, attempt to upload something

Relevant Code:

self.importScripts('https://unpkg.com/firebase@5.0.4/firebase.js')
...
self.firebase.storage().ref().child(filename).put(file)

throws Uncaught ReferenceError: XMLHttpRequest is not defined

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions