Skip to content Skip to sidebar Skip to footer

React Native Different Behaviour Between Debug Mode And Normal Mode

hi I have a really complicated problem. So I created a new repo for this problem at github. So you can clone it and see what the problem is. https://github.com/guitar9/hafas-client

Solution 1:

The problem is the usage of the Luxon library within hafas-client library. You will see that your code provided in the repo runs fine on iOS and on android only with remote debugging enabled. Why?

When remote debugging is enabled the code does not run in your phone but in the V8 engine of your chrome browser. When the remote debugging is disabled, code runs on your phone, where in case of android, it runs on a JavaScriptCore (JSC) engine from late 2014 that was compiled with custom setup for react native - that can, potentially, deliver different results.

As the luxon docs point out, support for react native on android is limited.

On iOS, react native uses the JSC available from the OS, which also includes intl features. The reason JSC on android does not have int support is that JSC is bundled together with the apk, and compiling it with intl support would increase the apk size by several MB.

With a bit of cutomizations (forking the hafas client) and working around the date problems, I believe you should be able to fix this. You may also use this but beware that you may run into other sorts of issues that may be hard to get help with (for a while, the Expo client used to use the JSC compiled from this repo but they had to stop using the custom build because of some problems).

Alternatively, you may try using intl polyfill

How did I find out? here you'll see that the error object contains a bunch of extra information. When you were logging the error, you were just getting the description field, but if you log the request field, you'll see that it contains "outDate": "Invalid DateTime". There it is!

Solution 2:

Author of hafas-client here. Posting as an answer for visibility and because I don't have the reputation to comment.

As I have documented in https://github.com/public-transport/hafas-client/issues/56#issuecomment-399915315, I managed to use hafas-client@3.0.0-alpha.9 out-of-the-box in react-native, after I had added the node-libs-react-native shims. Please try this.

There might of course be another issue related to luxon (as discussed in https://stackoverflow.com/a/51005700), but at least querying data without EPARSE errors or undecoded response payloads are not related to luxon and apparently solved.

Post a Comment for "React Native Different Behaviour Between Debug Mode And Normal Mode"