googlearchive / firebase-util

An experimental toolset for Firebase
http://firebase.github.io/firebase-util
MIT License
276 stars 67 forks source link

NormalizedCollection issue with Ionic and iOS 9 #65

Open alexford436 opened 8 years ago

alexford436 commented 8 years ago

Hi, I have several normalized collections that I use in an Ionic Framework application that worked perfectly when built for iOS 8. Since upgrading to iOS 9, Normalized collection can no longer be used, always yielding the following error:

"Error: Each argument to the NormalizedCollection constructor must be a valid Firebase reference or an Array containing a Firebase ref as the first argument."

The arguments are perfectly valid Firebase references.

Any idea of why the Firebase references would be interpreted differently? iOS 9 has restricted network requests to specific forms of TLS only, but I have explicitly allowed for all arbitrary http traffic to pass through.

Thank you for any help or insight!

devlift commented 8 years ago

I am experiencing the same issue. Is there a workaround that anyone knows of?

alexdabast commented 8 years ago

Same issue seems to be linked to new safari ES implemtation I don't have a workaround yet and I'm pretty sure that is apple issue @katowulf should submit a ticket to apple for a fix asap !

katowulf commented 8 years ago

Please submit a minimal repro if possible. It may be an issue with safari/ES, but if we can repro locally, our API team may be able to find some workarounds. Cheers.

alexdabast commented 8 years ago

Here we go https://github.com/alexdabast/firebaseios9bug

Here is the error log

Error: Each argument to the NormalizedCollection constructor must be a valid Firebase reference or an Array containing a Firebase ref as the first argument assertPaths@http://192.168.0.9:8100/lib/firebase-util/dist/firebase-util.js:657:20 NormalizedCollection@http://192.168.0.9:8100/lib/firebase-util/dist/firebase-util.js:605:14

I used the same example as http://firebase.github.io/firebase-util/#/toolbox/NormalizedCollection/example/users

@katowulf any news ? :)

jawgardner commented 8 years ago

I have this issue also.

avinashjavaji commented 8 years ago

Exact same issue with our code/use of firebase-util.

Edit based on katowulf's comment below:

Sorry katowulf, I assumed it was clear cause it was very similar to what's been described so far. My bad.

Ionic version: 1.6.4 Firebase Version: 2.2.9 Firebase Util Version: 0.2.5 Tested on iPhone 5s device and iPhone 6 emulator both running on iOS9 Error: Each argument to the NormalizedCollection constructor must be a valid Firebase reference or an Array containing a Firebase ref as the first argument. Things were working fire till iOS 8 and are still working just fine on Android and Desktop Browsers.

katowulf commented 8 years ago

Gents, if you have additional info to provide (version info, steps to repro) then please include it. Posting "same issue" is of no use to anyone without additional info on resolution.

alexdabast commented 8 years ago

Isn't my repo enough?

bogdantmm92 commented 8 years ago

I also get the same error on iOS 9, both chrome and safari, latest version of firebase and firebase-utils, using the sample code you provide : Each argument to the NormalizedCollection constructor must be a valid Firebase reference or an Array containing a Firebase ref as the first argument.

alexdabast commented 8 years ago

Guys my workaround is to remove the check of arguments from the firebaseutils code inside your firebase-utils.js at line 657 replace the code by the following if( util.contains(args, notValidRef) ) { return; throw new Error('Each argument to the NormalizedCollection constructor must be a ' + 'valid Firebase reference or an Array containing a Firebase ref as the first argument'); }

this is will simply bypass any check on the arguments so be sure to use valid arguments ! Be sure to use version 0.2.5 of firebase utils I'm a little confused that nobody give a workaround isn't there any major app using firebase utils ?

katowulf commented 8 years ago

@puf made some progress today. It looks like Safari on iOS 9 is returning the following:

> Object.prototype.toString.call(vals)
< "[object Arguments]"

Thus, because iOS 9 because is returning [object Arguments] (probably a breaking change for ES6 compliance?), when you are using an array as the argument for a reference into NormalizedCollection, Safari is incorrectly identifying this as "not an array". I'll look into a fix.

A quick guess is that Array.isArray is busted by this, but it shouldn't be too hard to fix.

jameswnl commented 8 years ago

Hi @katowulf How can I get this fix? Do I have to wait till 0.2.6 release? I need this fix asap.

Thanks

puf commented 8 years ago

I'm pretty sure this line should be using isArrayLike() instead of isArray(): https://github.com/firebase/firebase-util/blob/master/src/common/libs/util.js#L187

On Tue, Sep 29, 2015 at 8:34 PM James Wong notifications@github.com wrote:

Hi @katowulf https://github.com/katowulf How can I get this fix? Do I have to wait till 0.2.6 release? I need this fix asap.

Thanks

— Reply to this email directly or view it on GitHub https://github.com/firebase/firebase-util/issues/65#issuecomment-144273074 .

maksymilian-majer commented 8 years ago

@jameswnl for now you can install using bower from my fork, that I created before the official bower repository is updated to the new version. To do this use this command: bower install https://github.com/maksymilian-majer/firebase-util.git

jameswnl commented 8 years ago

@maksymilian-majer, thanks. I'm a newbie to JavaScript. Currently, I'm using firebase-util in a web app by having a < script> tag pointing to the cdn version. So in this case, I guess I have to create a copy on the web server and make the script tag point to it. How do i "compile"/ (pack) one for this purpose? I am assuming tends a way to collapse all the files into one for the web app purpose. If there's a doc about this, appreciate any help on this. Thanks

jameswnl commented 8 years ago

Just read about bower, i think i got it. Sorry, was being lazy before :(

jameswnl commented 8 years ago

@maksymilian-majer it solved the problem. Thanks a lot!

maksymilian-majer commented 8 years ago

@jameswnl You're welcome :)

jasonpearson commented 8 years ago

any plans to include this fix in a new release available through npm? If anyone else is having the same problem, I had to clone the project repo and run gulp bundle in order to get the firebase-util.min.js with the fix in it

bpkennedy commented 8 years ago

I also would appreciate a new release. I just tried what @jasonpearson recommended, but Gulp was failing to bundle for me.

ghost commented 8 years ago

Same issue on my side. Any update on this?

$ ionic info Your system information: Cordova CLI: 5.4.1 Gulp version: CLI version 3.9.0 Gulp local: Local version 3.9.0 Ionic Version: 1.2.4 Ionic CLI Version: 1.7.14 Ionic App Lib Version: 0.7.0 ios-deploy version: 1.8.3 ios-sim version: 5.0.4 OS: Mac OS X El Capitan Node Version: v0.12.7 Xcode version: Xcode 7.2 Build version 7C68

bpkennedy commented 8 years ago

For now, I'm just getting @maksymilian-majer's release which has it updated.

Puigcerber commented 8 years ago

Thank you @maksymilian-majer for the release!