Skip to content

Storage: TypeError thrown when UploadTask#on observer is missing some methods #40

@jsayol

Description

@jsayol

[REQUIRED] Describe your environment

  • Operating System version: Linux & Windows 10
  • Firebase SDK version: 4.1.1
  • Firebase Product: storage

[REQUIRED] Describe the problem

According to the documentation, the nextOrObserver parameter for the firebase.storage.UploadTask#on method should accept an observer with only some of the methods: next, complete, and error.

That means this should be allowed:

uploadTask.on(TaskEvent.STATE_CHANGED, {
  next: (snapshot) => { console.log(snapshot); },
  error: (err) => { console.error(err); }
});

This, though, raises the following error: TypeError: Cannot read property 'bind' of undefined since observer.complete is undefined. Relevant code here.

Currently, the only workaround besides providing an actual method is this:

uploadTask.on(TaskEvent.STATE_CHANGED, {
  next: (snapshot) => { console.log(snapshot); },
  error: (err) => { console.error(err); },
  complete: null
});

Steps to reproduce:

See JS Bin link below.

Relevant Code:

http://jsbin.com/yujaraboma/1/edit?js,console

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