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

Invalid path: /storage/emulated/0 #320

Closed
jslok opened this issue Feb 11, 2018 · 8 comments
Closed

Invalid path: /storage/emulated/0 #320

jslok opened this issue Feb 11, 2018 · 8 comments

Comments

@jslok
Copy link
Contributor

jslok commented Feb 11, 2018

Summary

Version 0.15.1
Affected OS Android
OS Version seen on 7.1, 7, 6, 4.22 so far

Current behavior

App crashes on start for some users. I'm seeing this error in Bugsnag:

com.facebook.react.common.JavascriptException Java exception in 'NativeModules'

java.lang.IllegalArgumentException: Invalid path: /storage/emulated/0, stack:
android.os.StatFs.doStat@46
android.os.StatFs.@39
com.learnium.RNDeviceInfo.RNDeviceModule.getFreeDiskStorage@137
com.learnium.RNDeviceInfo.RNDeviceModule.getConstants@224
com.facebook.react.bridge.JavaModuleWrapper.getConstants@140
android.os.Handler.handleCallback@751
android.os.Handler.dispatchMessage@95
com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage@31

Expected behavior

App should start normally. As far as I can tell, 0.14.x and the issue only started happening on 0.15.x.

Any help would be much appreciated.

@machour
Copy link
Contributor

machour commented Feb 12, 2018

Hi @jslok and thank you for reporting this issue. getFreeDiskStorage() was indeed added in 0.15.0 and this line seems to be the culprit.

Are you able to reproduce the issue on your own?

@jslok
Copy link
Contributor Author

jslok commented Feb 12, 2018

@machour Unfortunately I cannot reproduce it. It does not seem to affect many users so far. One user said he was able to solve the issue on his own by uninstalling then reinstalling my app several times but of course that is not really a good solution.

@machour
Copy link
Contributor

machour commented Feb 12, 2018

of course it's not. Maybe surrounding the block with a try/catch could help.
Do you want to open a PR with this solution?

@jslok
Copy link
Contributor Author

jslok commented Feb 12, 2018

@machour you can go ahead and take care of it if you dont mind.

@jslok
Copy link
Contributor Author

jslok commented Feb 12, 2018

Still new to git and never done a pr before.

@machour
Copy link
Contributor

machour commented Feb 12, 2018

I could do it, but I can also help you out doing your first PR ever, and I think this would be even cooler for you and it would definitely make my day 😄

give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime

Basically you would do the following:

  • fork this repository into your account:

screen shot 2018-02-12 at 12 12 55 pm

  • clone your fork:
    git clone [email protected]:jslok/react-native-device-info.git

  • create a new branch to work on:
    git checkout -b 320-fix-getfreediskspace

  • make your changes

  • commit your change with a meaningful message:

git commit -m "fix: surround StatsFS call with try/catch" android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java
  • push the changes to your branch:
git push --set-upstream origin 320-fix-getfreediskspace
  • head over to your fork on GitHub, you should see a yellow box like this:

screen shot 2018-02-12 at 12 19 57 pm

  • click on "Compare & pull request"

  • validate the changes on next screen (make sure you fill the PR template)

  • Get you first Pull Request ever merged, then brag about it to your friends ❤️

PS: I'm available on Twitter or Gitter if you need assistance.

jslok added a commit to jslok/react-native-device-info that referenced this issue Feb 12, 2018
* Fix crash on `getFreeDiskStorage` from invalid filesystem path (react-native-device-info#320)
@jslok
Copy link
Contributor Author

jslok commented Feb 12, 2018

Ok!! Hope I did it right and thank you for the detailed instructions. Let me know if there's anything wrong with it. I shall be much more helpful on github from now on.

@machour
Copy link
Contributor

machour commented Feb 12, 2018

This is so great, thank you for the pull request! 🎉 🎉 🕺
I left you some remarks there that needs taking care of.

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

2 participants