Skip to content

RN crash with latest 1.10.1 #496

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
kelset opened this issue Oct 23, 2017 · 24 comments · Fixed by #519
Closed

RN crash with latest 1.10.1 #496

kelset opened this issue Oct 23, 2017 · 24 comments · Fixed by #519

Comments

@kelset
Copy link

kelset commented Oct 23, 2017

Hello.
This morning I've tried to update the package to the new release 1.10.1 but the packager returns this error:

error: bundling failed: UnableToResolveError: Unable to resolve module `react-native/Libraries/react-native/react-native.js` from `/<...app_path>/node_modules/parse/lib/react-native/StorageController.react-native.js`: Module does not exist in the module map

I think it may be related to e0ac255


Edit: I'm using react-native: 0.49.

@flovilmart
Copy link
Contributor

flovilmart commented Oct 23, 2017

@kelset do you have the path where AsyncStorage is exposed on react-native: 0.49?

@kelset
Copy link
Author

kelset commented Oct 23, 2017

I'm not sure I've understood your question... by looking at the docs it doesn't seem AsyncStorage is exposed in any particular/new way...?

@xcarpentier
Copy link

xcarpentier commented Oct 23, 2017

RN 0.49.3
Into ./node_modules/react-native/Libraries/Storage/AsyncStorage.js
@flovilmart

@flovilmart
Copy link
Contributor

Wonderful!

@flovilmart
Copy link
Contributor

TBH, it’s driving me crazy all those changes, would you guys be OK with providing the AsyncStorage class instead of the SDK fighting to figure out what to do?

@flovilmart
Copy link
Contributor

@arniu thoughts?

@arniu
Copy link
Contributor

arniu commented Oct 24, 2017

RN 0.40.0 passed!

@flovilmart
Copy link
Contributor

Yeah hopefully, and 0.43+ should pass now as well but 0.49 is broken

@AlexisJamin
Copy link

Same problem today when I upgraded Expo SDK to v22.0 (RN 0.49).

Solved it by putting back :

import { AsyncStorage } from 'react-native/Libraries/react-native/react-native-implementation';

instead of :

let AsyncStorage;
try {
// for React Native 0.43+
AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
} catch (error) {
AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
}

Any idea why it's working that way again ?

@flovilmart
Copy link
Contributor

man it drives me crazy, we'Ll let you guys provide the async storage library on your own no? That seems safer for the long run

@kelset
Copy link
Author

kelset commented Oct 24, 2017

You mean like exposing an option to pass in to Parse the storage to use? (like redux-persist?)

@flovilmart
Copy link
Contributor

Yep, that's the idea!

@AlexisJamin
Copy link

Please make it simple for beginners like me ! ^^

@flovilmart
Copy link
Contributor

@AlexisJamin it's not about making it simple but just making it work.

@jcguarinpenaranda
Copy link
Contributor

I'm using react-native@^0.50.2 and I'm having the same issue. How can I fix this?

@jcguarinpenaranda
Copy link
Contributor

For RN 0.50.2, found the solution in parse/lib/react-native/StorageController.react-native.js. Changed to the following:

captura de pantalla 2017-11-07 a las 5 31 14 p m

jcguarinpenaranda added a commit to owsas/Parse-SDK-JS that referenced this issue Nov 8, 2017
Added other try-catch to require the correct library for React Native 0.50+, as posted on [parse-community#496](parse-community#496)
@kelset
Copy link
Author

kelset commented Nov 9, 2017

Thanks @jcguarinpenaranda for the PR, can't wait for it to be merged & released :)

@mcwebb
Copy link

mcwebb commented Nov 9, 2017

In the meantime, as a workaround you can add a postinstall bash script in package.json. Something like:

#!/bin/bash
PARSE_FILENAME='./node_modules/parse/lib/react-native/StorageController.react-native.js'

sed -i '' -e '16,21d' $PARSE_FILENAME
sed -i '' -e 's|let AsyncStorage|let AsyncStorage = require("react-native/Libraries/Storage/AsyncStorage")|g' $PARSE_FILENAME

(OS X, Parse 1.10.1, RN 0.50)

@ramyareye
Copy link

I'm using version 0.48.2 and every time I yarn it give me same error and I have to hard code!
I change

let AsyncStorage;
try {
  // for React Native 0.43+
  AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
} catch (error) {
  AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
}

to :

// let AsyncStorage;
// try {
  // for React Native 0.43+
  AsyncStorage = require('react-native/Libraries/react-native/react-native-implementation').AsyncStorage;
// } catch (error) {
//   AsyncStorage = require('react-native/Libraries/react-native/react-native.js').AsyncStorage;
// }

So it starts working well! any idea ?

natanrolnik pushed a commit that referenced this issue Nov 22, 2017
Added other try-catch to require the correct library for React Native 0.50+, as posted on [#496](#496)
@kelset
Copy link
Author

kelset commented Nov 23, 2017

Any update on when the fix for this (aside from the postinstall suggestion) will come out?

Asking because @natanrolnik merged the PR and then reverted it :/

@10thfloor
Copy link

10thfloor commented Dec 1, 2017

Breaks with these:
"parse": "^1.10.2",
"react": "16.0.0",
"react-native": "0.50.3"

Replacing the AsyncStorage require in StorageController.react-native.js with this:
import { AsyncStorage } from "react-native/Libraries/react-native/react-native-implementation"; fixes things.

@flovilmart
Copy link
Contributor

As things are turning I guess we’re gonna require the clients to set their async storage manually with something like Parse.setStorage()

@JulienKode
Copy link

Nice idea ! 😊

@flovilmart
Copy link
Contributor

Alright, i’ll work on a PR for this

flovilmart referenced this issue Dec 11, 2017
* Adds interface to externally set RN Async Storage

* mark method as static

* possible speedbump for travis:

http://facebook.github.io/jest/docs/en/troubleshooting.html\#tests-are-extremely-slow-on-docker-and-or-continuous-integration-ci-server

* use mongodb-runner
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants