Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jsayol opened this issue Jun 7, 2017 · 3 comments

Comments

@jsayol
Copy link
Contributor

jsayol commented Jun 7, 2017

[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

@google-oss-bot
Copy link
Contributor

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

@jsayol
Copy link
Contributor Author

jsayol commented Jun 8, 2017

PR merged, closing!

@jsayol jsayol closed this as completed Jun 8, 2017
@ghost
Copy link

ghost commented Sep 19, 2017

Looks this is still a issue - i am getting this > Cannot read property 'snapshot' of undefined
at Observer.complete

@firebase firebase locked and limited conversation to collaborators Oct 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants