Skip to content
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

File.readAsArrayBuffer promise never resolves #1530

Closed
peterpeterparker opened this issue May 11, 2017 · 14 comments
Closed

File.readAsArrayBuffer promise never resolves #1530

peterpeterparker opened this issue May 11, 2017 · 14 comments
Assignees

Comments

@peterpeterparker
Copy link
Contributor

peterpeterparker commented May 11, 2017

Hey,

I updated recently to Cordova 7.0.0, cordova-plugin-file 4.3.3 and today ionic-native 3.6.1 and ionic-angular 3.2.0.

After all these update, File.readAsArrayBuffer promise is never resolved.

I tried without luck solution described in #978 and #505 (polyfill.js before cordova.js in index.html ... didn't worked).

Best regards

P.S.: For the record, same behavior tested on iPhone (6) and Android (Samsung Edge)

My info:

global packages:

@ionic/cli-utils : 1.0.0
Cordova CLI      : 7.0.0 
Ionic CLI        : 3.0.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.0.0
@ionic/cli-plugin-ionic-angular : 1.0.0
Ionic Framework                 : ionic-angular 3.2.0

System:

Node       : v7.2.1
OS         : macOS Sierra
Xcode      : Xcode 8.3.2 Build version 8E2002 
ios-deploy : 1.9.0 
ios-sim    : 5.0.13 
@SirTori
Copy link

SirTori commented May 11, 2017

I updated to these versions today coming from ionic 2 (except I updated ionic-native to 3.7) and ran into the same issue.

After playing around a bit with different versions of cordova, zone.js, rxjs, sw-toolbox, ionic-native I found a working one:
ionic-native/*@3.4.4
changing any other library did not seem to have any effect on this bug. After finding the correct ionic-native version I upgraded the other libraries again and it keeps working.

I would very much appreciate a fix for 3.7 - I would like to try out the new document-viewer plugin.

P.S.: All my testing was done with the workaround as described in #505 (polyfill.js before cordova.js in index.html) in place

@yackermann
Copy link

@peterpeterparker @SirTori same issue here. Tested with readAsText. Drives me nuts!

@yackermann
Copy link

@SirTori YOU ARE MY HERO!

@zjw1918
Copy link

zjw1918 commented May 11, 2017

Same problem.
Both happened in [ ionic 3.0.0, cordova 7.0.0, android 7.0 ] and [ ionic 2.2.3, cordova 6.5.0, android 4.4 ].
If the file to be read does not exist, catch can get FILE NOT EXIST. If file does exist, read callback just does not happen.

@yackermann
Copy link

@zjw1918 @SirTori temporary solutions works perfectly!

@zjw1918
Copy link

zjw1918 commented May 11, 2017

@herrjemand Yes, thanks. Just need to change "ionic-native/file" version to 3.4.4.

@SirTori
Copy link

SirTori commented May 11, 2017

Glad this helps some people.

It seems many are eager to update to the newest versions these days, a shame it (re)introduces this bug.
Since no errors are thrown its hard to debug and if you don't use the right keywords to find these issues here many hours can get lost to this.

This is a pretty old issue (#505) that was closed without a resolution but just a workaround (which wasn't even added to the examples and templates - so everyone using these plugins is bound to run into this). I hope now that the workaround doesn't work anymore since 3.6.1 (don't know about 3.5) and the issue is brought up again, a real solution will be seeked.

@peterpeterparker
Copy link
Contributor Author

peterpeterparker commented May 11, 2017

@SirTori I don't think this bug was reintroduced. I use ionic-native for File.readAsArrayBuffer since version alpha and I never had to use the workaround described in the issues I linked above.

@troyanskiy
Copy link
Contributor

I have same issue with file.readAsText, which is never resolved.
I think the issue is related to simplify commit, which suppose to have common code for readAsArrayBuffer, readAsText...
I will try to dig on it.

@troyanskiy
Copy link
Contributor

So... I've fixed the issue.
It works for me.
PR created.

ihadeed pushed a commit that referenced this issue May 12, 2017
Pass reader object on call function.
Fixes #1530
@pliablepixels
Copy link

pliablepixels commented Jul 23, 2017

@ihadeed is this fixed? I am having the same problem of this function not resolving.

my native-version:

npm list | grep native
├── @ionic-native/android-permissions@4.0.1
├── @ionic-native/core@4.1.0
├── @ionic-native/device-motion@4.0.1
├── @ionic-native/file@4.1.0
├── @ionic-native/geolocation@4.1.0
├── @ionic-native/gyroscope@4.0.1
├── @ionic-native/insomnia@4.0.1
├── @ionic-native/social-sharing@4.0.1
├── @ionic-native/splash-screen@4.1.0
├── @ionic-native/status-bar@4.1.0

I've modified index.html script order as such:

 <!-- The polyfills js is generated during the build process -->
  <script src="build/polyfills.js"></script>


  <!-- cordova.js required for cordova apps. AFTER POLYFILL -->
  <script src="cordova.js"></script>

  <!-- The vendor js is generated during the build process
       It contains all of the dependencies in node_modules -->
  <script src="build/vendor.js"></script>

  <!-- The main bundle js is generated during the build process -->
  <script src="build/main.js"></script>

ionic info

ionic info

global packages:

    @ionic/cli-utils : 1.5.0
    Cordova CLI      : 7.0.1 
    Ionic CLI        : 3.5.0

local packages:

    @ionic/app-scripts              : 2.0.2
    @ionic/cli-plugin-cordova       : 1.4.1
    @ionic/cli-plugin-ionic-angular : 1.3.2
    Cordova Platforms               : android 6.2.3 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.5.3

System:

    Node       : v8.1.4
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.0 
    ios-sim    : 5.0.2 
    npm        : 5.0.3 

thanks

@ihadeed
Copy link
Collaborator

ihadeed commented Jul 23, 2017

@pliablepixels what platform?

@pliablepixels
Copy link

@ihadeed I was about to delete my question but you responded - thankyou :-) running in iOS (host is OS X). I resolved the issue by removing and adding iOS platform

@cnadeau
Copy link

cnadeau commented Sep 22, 2017

I still have that issue on iOS simulator 10.2, MacOS El-Captain

image

But the problem seems to be more related to the fact that UInt8Array is undefined for some reason and it just throws within the actual onReadSuccessCallback and the onerror is never called fromt there for X reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants