50

I am building a react-native app that I recently moved to expo. The app seems to display the expected screen, but before it completes, I am receiving the following error message: console.error: "There was a problem sending log messages to your development environment, {"name": "Error"}". When I view the expo browser screen I see the following stack trace when I click on the device:

  node_modules/expo/build/logs/LogSerialization.js:146:14 in _captureConsoleStackTrace
  node_modules/expo/build/logs/LogSerialization.js:41:24 in Object.serializeLogDataAsync$
  node_modules/regenerator-runtime/runtime.js:62:39 in tryCatch
  node_modules/regenerator-runtime/runtime.js:288:21 in Generator.invoke [as _invoke]
  node_modules/regenerator-runtime/runtime.js:114:20 in Generator.prototype.(anonymous
  node_modules/regenerator-runtime/runtime.js:62:39 in tryCatch
  node_modules/regenerator-runtime/runtime.js:152:19 in invoke
  node_modules/regenerator-runtime/runtime.js:187:10 in <unknown>
  node_modules/promise/setimmediate/core.js:45:4 in tryCallTwo
  node_modules/promise/setimmediate/core.js:200:12 in doResolve

Here is a screenshot of the error:

enter image description here

What does this error mean? I found some doc referring to removing console.log statements and removed the ones I had but that did not help.

3
  • I also ran into this today. What expo version are you running? Commented Feb 4, 2019 at 18:34
  • "expo": "^32.0.0" Commented Feb 5, 2019 at 2:45
  • Same problem here. I used the expo iOS Client and scanned the qr code from the metro bundler. After I want to send a console.log() I get this error. Commented Feb 15, 2019 at 11:27

9 Answers 9

107

This is due to the fact that the React native console logger CANNOT parse the JSON object coming from Axios or some other library, or it's too big. In older Expo/RN versions, it's most likely that anyone who is having this error is not PARSING the JSON object before logging it to the console, or it's too big.

CODE THAT MIGHT GIVE THIS ERROR:

Axios.post(URL).then(function (response)
{
console.log("POST RESPONSE: "+response);
}

CODE THAT MIGHT FIX THIS ERROR:

Axios.post(URL).then(function (response)
{
console.log("POST RESPONSE: "+JSON.stringify(response));
}

OR (as mentioned in the comments):

Axios.post(URL).then(function (response)
{
console.log("POST RESPONSE: ",response);
}
3
  • I am still getting the following error even though i'm wrap it with JSON.stringify JSON.stringify cannot serialize cyclic structures... signOut = async () => { console.log(JSON.stringify(this.props)); NavigationService.navigate("Auth"); await AsyncStorage.clear(); await this.props.client.resetStore(); }; Without wrapping JSON.stringify, i will get the warning "There was a problem sending log messages..." anyone has a solution? Eagerly awaiting Expo to resolve this console log error!!!
    – Hendry Lim
    Commented Apr 29, 2019 at 4:54
  • 3
    Thanks!!! Instead i got an error of value.hasOwnProperty when logging the result in console.
    – domster
    Commented Mar 30, 2020 at 13:09
  • or simply console.log('POST RESPONSE:', response) will do Commented Jan 11, 2022 at 22:38
34
TL;DR

This issue only happens when you log an object which is too big for console.log function to display. So when ever logging the response from an API or Server be sure to destructure it properly and only keep the data you need.


For anyone who wants a more detailed answer to this issue, please keep reading..

I ran into this weird error as well this morning. I am developing in react native with Expo Client for an app I'm building with the popular MERN stack (mongoDB, Express, React Native and Node.js). I am mentioning that because I use a lot, I mean A LOT of console logs in the backend and this didn't cause me any problem thus far. So in my case, I was not sure if this error originated from any console.log I was using.

I checked the expo debugger's stacktrace in the console (in port 19001), because the red screen doesn't provide much info on the origin of the error (a lot of <unknown> in place of functions) and I saw that it had something to do with my actions functions and the payload I was sending to my reducer when I performed a specific action that was communicating with the backend. The backend's response was formatted like this:

payload: {
  config: {
     .
     .
     .
 }
 data: { the only part that i needed... }
 headers: {
    .
    .
    .
}

..other stuff from the response..

There's not much to notice above, but this:

The actual paylaod I was interested in is under the prop key data and was the only thing I needed from the response. BUT, in my ignorance I was sending everything to my reducer. So what I am saying is that I was sending a really big object as payload and I only needed a part of it. So when I did some destructuring and kept the data that I mentioned above, the error went away.

In conclusion, for others that may stumble across this "error" which isn't actually an error, because the app doesn't crash or anything, since you can dismiss the window and the app goes on, when you do some fetching from the server, make sure you keep only the data and not the whole response object, along with the meta from the call. It seems that redux-logger throws this because it doesn't like the structure of it.

4
  • 1
    Please, don't use images for code, errors or textual data. Post those as text, so that we can reuse the data without having to re-type everything, and your answer can be properly indexed or read by screen readers.
    – Martijn Pieters
    Commented Feb 16, 2019 at 15:40
  • Thank! just the confirmation that this isn't an actual error was super helpful!
    – Chris
    Commented Apr 21, 2020 at 20:55
  • Helpful, I was trying to log the whole response object, so I just kept data and it works!!
    – Meana
    Commented Jul 1, 2021 at 12:04
  • How are you able to use Expo with NodeJS?
    – Erick Adam
    Commented Oct 20, 2022 at 0:22
15

To simplify all the answers above, This issue only happens when you log an object which is too big for console to display. So when ever logging the response from an API or Server be sure to add JSON.stringify(result). This resolved the issue for me.

10

I have also ran into this issue but due to other causes.

BACKGROUND:

Project stack (Just what is important to the error) :

expo: ^34.0.1 react-native: SDK 34 react-navigation: 4.0.5 react-navigation-drawer: ^2.2.1

In this project I was not using react-redux or axios I'm actually using graphql , @apollo/react-hooks and apollo-boost to take care of network requests and local state management.

ANSWER:

As you can see in the BACKGROUND, I am using react-navigation. I was creating a drawer navigator with createDrawerNavigator according to the React Navigation API

I wanted to use the contentComponent property of the DrawerNavigatorConfig to create custom DrawerNavigatorItems.

I put and anonymous arrow function in the contentComponent property with the only argument of props.

THIS CAUSED THE ERROR:

I placed a console.log() inside the anonymous arrow function I mentioned above

I received the error on my iOS simulator that read: `console.error: "There was a problem sending log messages to your development environment"

See my code below:

import {createDrawerNavigator, DrawerNavigatorItems} from "react-navigation-drawer";
import ProfileNavigator from "../Profile/Profile";
import Colors from "../../constants/colors";
import {AsyncStorage, Button, SafeAreaView, View} from "react-native";
import React from "react";
import {Logout} from "../Common";
import HomeNavigator from "../Home/Home";

const AppDrawerNavigator = createDrawerNavigator(
    {
        Profile: ProfileNavigator
    },
    {
        contentOptions: {
            activeTintColor: Colors.primary
        },
        contentComponent: props => {
            console.log(props) // THIS IS THE ISSUE CAUSING THE ERROR!!!!!!
            return (
                <View style={{ flex: 1, paddingTop: 20 }}>
                    <SafeAreaView forceInset={{ top: 'always', horizontal: 'never' }}>
                        <DrawerNavigatorItems {...props} />
                        <Button
                            title="Logout"
                            color={Colors.primary}
                            onPress={Logout}
                        />
                    </SafeAreaView>
                </View>
            )
        },
        drawerType: 'slide',
        unmountInactiveRoutes: true
    }
)

export default AppDrawerNavigator
9

I got this error consistently when dumping the result of a fetch call to console like: console.log(result).
Once I used:

console.log(JSON.stringify(result)) 

the problem went away.

2

I had the same issue today and the fix was to add response.json()

              fetch(endpoint, {
                method: 'GET',
                headers: {
                  Accept: 'application/json',
                }
              })
                .then(response => response.json())
                .then(response => {
                  console.log('response', response)
                })
2

This is the problem that comes with console.log (In VSCode, Ctrl + Shift + F to search all then type console.log to find where it is).

Convert from

console.log(error.config);

to

console.log(JSON.stringify(error.config, null, 2));

(null, 2 is to keep the print pretty)

enter image description here

0

Objects being sent to console.log are causing the red screen. As others noted you need to stringify all objects.

For those who don't have time to update every console.log in their app, simply do a global replace of console.log with a new function name (we used global.ourLog) and use this code to look at every param and stringify if an object. This function was put in the first line of our App.js of our expo app.

// this routine corrects the red screen
// of death with expo logging
// by taking objects that are logged and ensuring
// they are converted to strings
global.ourLog = function() {
     let s = ''
     for ( let a of arguments ) {
        if ( typeof a === 'string') {
           s += a
        } else if ( typeof a === 'number') {
           s += a
        } else {
           s += JSON.stringify(a,null,2)
        }
        s += '\t'
     }
     console.log(s)
}

then use like any other console.log (or replace every console.log with that new function name).

 global.ourLog( "a string", anObject, err)

Hope this helps someone, it saved us a ton of time.

0

we mostly pass our backend as res.json() this means when logging you should await res.json() as your log with this the result may be async function data(){ await fetch(url,{headers:{},})} const result=await data.json() console.log(result)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.