React-native: [Android][fetch] app crashes when response contains special character \u2028

Created on 24 Dec 2015  Â·  47Comments  Â·  Source: facebook/react-native

fetch('http://someurl');
if the response contains the character \u2028 , the app crashes with the following error
SyntaxError: Unexpected EOF (line 1 in the generated bundle)

It looks like a tricky character.
Try copy paste the below statement in your browser console, it should give you an error.
var invalidString = "s
." ;
The special character is between the "s" and the ".";

Running on react-native-0.16.0
This error does not appear during chrome debug mode.

AsyncStorage Locked

Most helpful comment

This is fixed by https://github.com/facebook/react-native/commit/6d3c7b8a4c1d1a0552a21cfabe03a8d1f344d1ed which should make it into the next release whether or not the new bridge is turned on by then.

All 47 comments

Hey han4wluc, thanks for reporting this issue!

React Native, as you've probably heard, is getting really popular and truth is we're getting a bit overwhelmed by the activity surrounding it. There are just too many issues for us to manage properly.

  • If you don't know how to do something or something is not working as you expect but not sure it's a bug, please ask on StackOverflow with the tag react-native or for more real time interactions, ask on Discord in the #react-native channel.
  • If this is a feature request or a bug that you would like to be fixed, please report it on Product Pains. It has a ranking feature that lets us focus on the most important issues the community is experiencing.
  • We welcome clear issues and PRs that are ready for in-depth discussion. Please provide screenshots where appropriate and always mention the version of React Native you're using. Thank you for your contributions!

@han4wluc What's your Content-Type set to?

cc @mkonicek

+1

react-native-0.16.0

Can you try 0.18.1? We don't have bandwidth to maintain older than the latest version unfortunately.

I'm seeing this error happening today using version 0.19.

Some weird characters make fetch fail crashing the app, we are having serious trouble with this bug. I'm trying to spot which characters are those, but haven't had luck yet.

Looks like u2028 is a line separator, indeed it also throws an error in the Chrome console. http://www.fileformat.info/info/unicode/char/2028/index.htm

@maraujop Sorry for the delay. Do you see anything in the output of 'adb logcat' you run on your machine showing a stack trace of where the parsing fails?

Hi @mkonicek ,

Sorry, for the delay too, I've been waiting for the app to crash with the same error, so I could report adb logcat Today it has finally shown up again, here is the stacktrace:

03-09 09:51:40.741 15820 16313 E ReactNative: Got JS Exception: SyntaxError: Unexpected EOF
03-09 09:51:40.741 15820 16313 E unknown:React: Exception in native call from JS
03-09 09:51:40.741 15820 16313 E unknown:React: com.facebook.react.bridge.JSExecutionException: SyntaxError: Unexpected EOF (<unknown file>:1)
03-09 09:51:40.741 15820 16313 E unknown:React:     at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.741 15820 16313 E unknown:React:     at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.741 15820 16313 E unknown:React:     at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.741 15820 16313 E unknown:React:     at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.741 15820 16313 E unknown:React:     at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.741 15820 16313 E unknown:React:     at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.741 15820 16313 E unknown:React:     at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.741 15820 16313 E unknown:React:     at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.750 15820 16313 W ReactNativeJS: Loading tab tomorrow failed
03-09 09:51:40.761 15820 16313 W ReactNativeJS: { [SyntaxError: JSON Parse error: Unexpected EOF]
03-09 09:51:40.761 15820 16313 W ReactNativeJS:   line: 65466,
03-09 09:51:40.761 15820 16313 W ReactNativeJS:   column: 10,
03-09 09:51:40.761 15820 16313 W ReactNativeJS:   sourceURL: 'http://10.4.0.50:8081/index.android.bundle?platform=android&dev=true&hot=false' }
03-09 09:51:40.905 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.905 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.905 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.905 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.914 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.914 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.914 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.914 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.920 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.920 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.920 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.920 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.928 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.928 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.928 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.928 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.934 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.934 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.934 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.934 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.941 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.941 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.941 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.941 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.947 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.947 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.947 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.947 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:40.950 15820 16313 W unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
03-09 09:51:40.951 15820 16313 W MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.951 15820 16313 W MessageQueue: java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {c2fc43d} sending message to a Handler on a dead thread
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.MessageQueue.enqueueMessage(MessageQueue.java:543)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.Handler.enqueueMessage(Handler.java:631)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageAtTime(Handler.java:600)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.Handler.sendMessageDelayed(Handler.java:570)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.Handler.post(Handler.java:326)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:60)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at com.facebook.react.bridge.ReactBridge.callFunction(Native Method)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at com.facebook.react.bridge.CatalystInstanceImpl$3.run(CatalystInstanceImpl.java:199)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.Handler.handleCallback(Handler.java:739)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.Handler.dispatchMessage(Handler.java:95)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at android.os.Looper.loop(Looper.java:148)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:184)
03-09 09:51:40.951 15820 16313 W MessageQueue:  at java.lang.Thread.run(Thread.java:818)
03-09 09:51:41.095  1289  1289 I Keyboard.Facilitator: onFinishInput()

I hope this helps, because this the only bug that's biting us in RN that really worries us.

Thanks, cheers
Miguel

I'm running into the same thing. It only seems to happen when I'm not debugging via Chrome though.

I've been seeing the same thing but only on Android 4.2 and below

I can confirm this is happening in a Moto G 3 with Android 6 and in a Nexus 5x Android 6, and a Nexus 5 Android 5.1

I think it's a runtime error occurring with JSON.parse?

We got the same issue with a list of posts; as far as we can see it has to do with a JSON length limit on Android. The JSON we use is valid, and if I limit the amount of posts we fetch it works as expected.

JSON parse error: Unrecognized token '< '

It looks like the JSON might be cut off at some point, if it's too long.

Tested on:
HTC One X - Android 4.4.4.

+1. Ran into this issue for Android only.

Has anyone made progress on this issue? It's a real real problem. My only solution has been to request data in very small chunks (doesn't seem to be a unicode issue for me) and return with a promise.all();

EDIT: maybe it is unicode, actually... it's just that the unicode character didn't appear until just AFTER my first threshold for a 'small chunk' of data.

Running into this issue on Samsung Galaxy S5 Android 5.0

We ended up finding that Android had a limit as to how large queries could be and so by chunking our data and queries we were able to get around this issue

@han4wluc recently we meet the exact same problem, I use react-native 0.24.1, crash in Android 5.1, but it is ok in iOS。

An api returns a json array, contains 100 items, crashed, at first, I thought it caused by too large body, so I reduce the items to 50, still crashed, then I continue to reduce to 25, still crashed. finally, I use bisection method, position the exact item that cause the crash. its content has no obvious strange when it displays in web browser, but when we goto the database console, print the content, it looks like this:

qq20160531-2

and when I try to parse it in chrome developer tools console, it also failed.

qq20160531-1

and following is the crash log by android logcat output, use adb logcat "*:S ReactNative:V ReactNativeJS:V" command to see.

qq20160531-3

so I don't think this is the bug of React-Native, and it should not be a bug, it is because your json content is not correct. it is just my opinion.

finally, how we resolve this problem, we fix it in server, we replace the \u2080 to '' when result returns. like this:

content = content.gsub(/\u2080/, '')  # ruby sample

at last, the only confuse me is that why it doesn't crash in iOS?

This was occurring to me as well. I haven't been able to determine if it occurs in JSON.parse or in AsyncStorage.getItem (I'm leaning towards either both or the latter) but my fix was to do a find and replace on my json text before storing it in AsyncStorage. I can confirm that it's not fetch that's actually crashing as it wasn't until the content was loaded from the cache that I was crashing (so the first time it would successfully fetch the content from the server then subsequently would crash when the cached data was retrieved). So my fix looked something like this:

if ( Platform.OS === 'android' && typeof text === 'string' )
{
  text = text.replace( /\\u2028|\\u2029/g, '' );
}

This is in my response handler in my API where text is the raw returned JSON from some request and this is done before JSON.parse as well as before AsyncStorage.setItem

Note that \u2029 will also cause this crash (not just the mentioned \u2028) and that JSON that is correctly encoded will write these characters as the literal string '\u2028'/'\u2029' which is why there's two backslashes in the strings

I'm also not sure why this only crashes on Android when not debugging in chrome

same issue. Android 4.4.2

+1 This issue is the biggest cause of crashes for our production app on Android.

We also think we are getting this error with the following stacktrace, this is a tough error to debug:

java.lang.RuntimeException: SyntaxError: Unexpected EOF (<unknown file>:1)
    at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
    at android.os.Handler.handleCallback(Handler.java:739)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
    at android.os.Looper.loop(Looper.java:158)
    at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:193)
    at java.lang.Thread.run(Thread.java:818)

Similarly, we believe that it is a JSON parsing issue, we’re running some searches in our database now to see if the characters mentioned show up.

@MITDelian, @baurine, @mangogogos: You’ve had more luck so far than us debugging this issue, and you all seem to have come to different solutions. Is there more information you could provide? Stack traces or other post mortem discoveries? @baurine you mentioned your issue was with \u2080, did you also have problems with \u2028?

@mkonicek: Could this be a bug in the Android JSON parsing library? Is this intended behavior? Is there anywhere we could compare the Android and iOS JSON parsing libraries to confirm this theory?

@calebmer we faced this issue and our solution was basically to try and make it never happen. Since we control every server that speaks to our app, we modified the servers to encode every unicode symbol in responses.

Then in the app we decode the unicode symbols like so:

function decodeUnicode(parent, index) {
  const r = /\\u([\d\w]{4})/gi;
  if (typeof parent[index] === 'string') {
    parent[index] = parent[index].replace(r, (match, grp) => {
      return String.fromCharCode(parseInt(grp, 16));
    });
  }
}

On the server this snippet represents what we do to encode unicode and get rid of newlines (which also breaks JSON):

row[i] = row[i].replace(/\r?\n/g, '\n').replace(/[\u0080-\uFFFF]/g, function(match) {
   return `\\u${('0000' + match.charCodeAt(0).toString(16)).slice(-4)}`;
});

@calebmer for me, my solution was to find and replace for these characters in the raw json text before doing anything with them (AsyncStorage.setItem/JSON.parse mostly)

// API.js
// ...
// ---------------------------------------------------------- getBodyCacheWriter
function getBodyCacheWriter( key, writeToCache = false )
{
  // get a response handler for some request that may write to cache via AsyncStorage
  return function( response )
  {
    return response.text()
                    .then( text =>
                    {
                      if ( Platform.OS === 'android' )
                      {
                        // see https://github.com/facebook/react-native/issues/4961
                        text = text.replace( /\\u2028|\\u2029/g, '' );
                      }
                      if ( writeToCache )
                      {
                        Cache.writeRawValue( key, text );
                      }
                      return text;
                    } )
                    .then( JSON.parse )
                    .catch( () =>
                    {
                      debug( response.url, 'returned invalid json' );
                      return {};
                    } );
  };
}
// ...

Then I can write fetch( somepath, someargs ).then( getBodyCacheWriter( someKey, writeToCache? ).then( json => successful json fetch ).catch( err => unsuccessful json fetch ) .done()

So for us this turned out to be a Async Storage issue. On Android the max dB size is 5 MB and max query size is 1 MB.

We ended up forking react native and compiling from source to up the max size to 50 MB and we shard all of our storage saves into 1 MB pieces and then remerge on the relaunch of the app.

We did not face the same character issue as others have.

@MITDelian I've noticed a warning about the storage size too, but I didn't do further research about that. Is there a cheap way to enlarge the default storage size for android?

I'm hitting this too in my personal project :( Looking into it now.

This is an error you get when you JSON.parse an empty string -- I haven't located which one it is yet but will look in more tomorrow. (it's possible that this could also trigger when we try to JSON.parse a string with bad characters: it basically just uses the standard JS parser that it uses to parse JS otherwise)

@nihgwu haha yeah, it's pretty easy but you do need to fork react native and then compile from source. there are instructions in their docs on how to do that for android, it's not too hard.

You don't actually need to change much code lol: https://github.com/nightingale/react-native/commit/f78138cdc3b9a5f3be0ea24f163f5ee2709d5205

Yep, this is definitely the problem. See this SO answer: http://stackoverflow.com/a/9168133

Luckily, in the new bridge we are shipping in the next release or two, we don't have this problem anymore. In the meantime, you can replace ResponseUtil.onDataReceived (used by the NetworkingModule) with this code if you're hitting this:

public static void onDataReceived(
    RCTDeviceEventEmitter eventEmitter,
    int requestId,
    String data) {
    String strippedData = data.replace("\u2028", "").replace("\u2029", "");

    WritableArray args = Arguments.createArray();
    args.pushInt(requestId);
    args.pushString(strippedData);

    eventEmitter.emit("didReceiveNetworkData", args);
  }

You can do this by compiling RN Android from source (sorry).

@foghina also has an idea about being able to manually enable the new bridge on RN master.

See ReactNativeHost#createReactInstanceManager() -- override that and just call setUseOldBridge(false) on the builder.

And then return your custom host from MyApplication#getReactNativeHost().

cc @bestander does the new bridge actually work in OSS like this?

It does not work in OSS yet, some build scripts need to be updated to be compiled properly but we are just a few steps away

I believe @astreet had a solution for this.

@javache Thanks.

I'm trying @astreet 's suggestion of modifying NetworkingModule. I think I might not have to build from source as modules can be overriden. Wish me luck.

Unfortunately I can no longer repro the issue locally. I'm gonna push an update with NetworkingModule change and see if I get any further crash reports.

Is this actually getting worse in the new release? Are we planning on doing a re-roll?

@astreet May be it's not the release. I certainly got a lot of crash reports after I upgraded. But it might as well be some user generated content.

Since the new bridge is gonna fix it and there's a workaround available right now, may be we can wait for next release.

Yeah, if the next release is going to have the fix then there's nothing to do really. But if we're not sure we're going to be releasing the new bridge (or are going to roll another release to fix this), then we should temporarily patch the networking module

@astreet Can send a PR if you want.

@bestander, do you know where the new bridge comes in with respect to our release schedule?

Once @mhorowitz and @cjhopman fix the build scripts for OSS we can enable the new bridge by default.
Branch 0.30 has been cut last week, better not to cherry-pick such a change into stable.
But 0.31 is going to be cut next Monday.

Ok, I'm not convinced we can rely on that. The networking fix will also cause perf issues. I'll send out a diff that fixes it properly in the old bridge.

This is fixed by https://github.com/facebook/react-native/commit/6d3c7b8a4c1d1a0552a21cfabe03a8d1f344d1ed which should make it into the next release whether or not the new bridge is turned on by then.

Thanks a lot @astreet

Cherry picking this to 0.29.1 and 0.30

Was this page helpful?
0 / 5 - 0 ratings