ignite icon indicating copy to clipboard operation
ignite copied to clipboard

ExceptionsManager.js:180 Unhandled promise rejection RangeError: Maximum call stack size exceeded when consume api

Open keyneslim opened this issue 3 years ago • 24 comments

What's going on?

Having ExceptionsManager.js:180 Unhandled promise rejection RangeError: Maximum call stack size exceeded

Steps to reproduce

  1. Init new Pizza App
  2. Go into demo list
  3. Press refresh to trigger the demo list one or two times
  4. ExceptionsManager.js:180 Unhandled promise rejection RangeError: Maximum call stack size exceeded is in the log Screenshot 2021-06-18 at 10 36 30 PM

ignite doctor results: System platform darwin
arch x64
cpu 12 cores Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz directory PizzaApp /Users/xx/Projects/PizzaApp

JavaScript (and globally-installed packages) node 16.0.0 /usr/local/bin/node npm 7.10.0 /usr/local/bin/npm
@angular/cli 11.2.11
http-server 0.12.3
npm 7.10.0
yarn 1.22.10
yarn 1.22.10 /usr/local/bin/yarn

Ignite ignite-cli 6.12.2 /Users/xx/.npm/_npx/e31027f3785124a8/node_modules/.bin/ignite
ignite src build /Users/xx/.npm/_npx/e31027f3785124a8/node_modules/ignite-cli/build

Android java 1.8.0_292 /usr/bin/java android home - undefined

iOS xcode 12.5
cocoapods 1.10.1 /usr/local/bin/pod

keyneslim avatar Jun 18 '21 14:06 keyneslim

I have the same issue but with the latest ignite as shown below. It's a very strange issue.

When a call is made using apisauce, it executes but does not return to the mobx state tree. However, if you console log response, it returns to the mobx state tree but gives the maximum call stack error

System
  platform           darwin
  arch               x64
  cpu                4 cores      Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  directory          docheck      /Users/***/workspace/***/***

JavaScript (and globally-installed packages)
  node                 14.17.0      /Users/***/.nvm/versions/node/v14.17.0/bin/node
  npm                  6.14.13      /Users/***/.nvm/versions/node/v14.17.0/bin/npm
    apollo             2.33.4
    appcenter-cli      2.9.0
    expo-cli           4.5.2
    ignite-cli         7.0.3
    json2csv           5.0.6
    live-server        1.2.1
    nhost              0.4.7
    npm                6.14.13
    passwordgen        0.3.0
    react-native-cli   2.0.1
    sqlite3            4.2.0
    yarn               1.22.10
  yarn                 1.22.10      /Users/***/.nvm/versions/node/v14.17.0/bin/yarn
    create-react-app   3.4.1
    ignite-cli         2.2.4

Ignite
  ignite-cli         7.0.3        /Users/***/.nvm/versions/node/v14.17.0/bin/ignite
  ignite src         build        /Users/***/.nvm/versions/node/v14.17.0/lib/node_modules/ignite-cli/build

Android
  java               12.0.1       /usr/bin/java
  android home       -            /Users/***/Library/Android/sdk/

iOS
  xcode              12.5
  cocoapods          1.10.1       /usr/local/bin/pod

osiloke avatar Jun 21 '21 22:06 osiloke

The problem seems to stem from the async methods in the api

osiloke avatar Jun 22 '21 05:06 osiloke

I'm also not sure about this. I also facing issue of MST Store is not working as expected in Release Mode, compare to debug mode. Guess i will let this boiler plate go :(

keyneslim avatar Jun 22 '21 17:06 keyneslim

This is a great boilerplate, however, there seems to be an issue with async and apisauce (axios) and use fetch in the api. If you make the method a sync method it should work.

i.e

getUsers(){
    return fetch(this.api.config.url, {
      method: "post",
      body: JSON.stringify(getEvents()),
    })
      .then((resp) => resp.json())
      .then((data) => ({
        kind: "ok",
        data,
      }))
  }
}

osiloke avatar Jun 22 '21 21:06 osiloke

Any updates on this? I'm probably facing the same issue.

imxeno avatar Jul 06 '21 20:07 imxeno

Any updates on this? I'm facing the same issue too.

Arnoldnuo avatar Jul 21 '21 03:07 Arnoldnuo

Any updates on this? I'm facing the same issue too.

You can use my workaround to bypass this bug as shown in the snippet below. The only difference here is that getUsers() is not an async function but returns an async function.

This is a great boilerplate, however, there seems to be an issue with async and apisauce (axios) and use fetch in the api. If you make the method a sync method it should work.

i.e

getUsers(){
    return fetch(this.api.config.url, {
      method: "post",
      body: JSON.stringify(getEvents()),
    })
      .then((resp) => resp.json())
      .then((data) => ({
        kind: "ok",
        data,
      }))
  }
}

osiloke avatar Jul 21 '21 08:07 osiloke

I'm also having this issue and unfortunately osiloke's workaround is not working for me.

Apophenian avatar Aug 01 '21 06:08 Apophenian

If you are not using expo, adding @babel/plugin-transform-async-to-generator to babel.config.js is a working workaround. If you are using expo, you're unfortunately out of luck.

imxeno avatar Aug 01 '21 08:08 imxeno

This worked for me. Thank you.

Apophenian avatar Aug 02 '21 00:08 Apophenian

Using Expo here and adding @babel/plugin-transform-async-to-generator to babel.config.js worked.

TrevPennington avatar Aug 12 '21 13:08 TrevPennington

Using Expo here and adding @babel/plugin-transform-async-to-generator to babel.config.js worked.

The issue still happen

sitanjob avatar Sep 03 '21 15:09 sitanjob

Using Expo here and adding @babel/plugin-transform-async-to-generator to babel.config.js worked.

Also using Expo, this didn't fix it. My console is full of these errors.

It is indeed very strange. Like @osiloke, I have to console.log to get the API calls to complete. However, I'm not using apisauce, I'm using amplify-js which uses axios internally.

I've tried tracking this error down but I have no idea where to find the issue and the error logs are not helpful at all. image

iamdavidmartin avatar Sep 10 '21 02:09 iamdavidmartin

I have this issue also with the latest ignite boilerplate version 7.5.0. Just apply the patch file on the new created app. 0001-test-useEffect-and-api-call.patch.zip

Steps to reproduce

  1. Init new app
  2. Apply patch
  3. Run in debug mode

Post comment The API call is made and the data is stored in the in the mobx-state-tree. And this is only occurring in the debug mode. As long as the data is always stored in the state-tree I think this error log can be ignored.

chreck avatar Sep 21 '21 08:09 chreck

I've managed to fix this (just as a workaround) by removing the <ToggleStorybook /> from app.tsx. For some reason, it seems that the Storybook wrapper is causing the issue.

poplaw avatar Sep 27 '21 14:09 poplaw

@poplaw It did the trick

thanhlmm avatar Oct 05 '21 03:10 thanhlmm

I've managed to fix this (just as a workaround) by removing the <ToggleStorybook /> from app.tsx. For some reason, it seems that the Storybook wrapper is causing the issue.

I'm going to piggyback this. As a newcomer to react native with this boilerplate, I ended up wasting 4 hours because my generator called an API and would not return to the caller. I don't know why this fixed it, but it did. :+1:

WalrusSoup avatar Oct 11 '21 01:10 WalrusSoup

I'm going to get someone on this issue -- thank you!

jamonholmgren avatar Oct 27 '21 19:10 jamonholmgren

Also worked for me. in case anyone else was having issues, this had been giving me a fit when trying to get expo-in-app-purchases to work as well

memyselfandm avatar Oct 30 '21 03:10 memyselfandm

I'm having the same issue with @nhost/hasura-auth-js crashing. Removing <ToggleStorybook /> as a workaround also did the trick.

potentially related issue: storybookjs/react-native#20

niieani avatar Dec 27 '21 10:12 niieani

if removing toggle storybook fixes this then you should check this again now that the fix in #1906 has been merged. You can also try applying the patch from the PR manually to your project.

dannyhw avatar Mar 08 '22 23:03 dannyhw

Even doing something like:

  useEffect(() => {
    console.log("USE EFFECT");
  }, [])

Was also triggering this for me

Unhandled promise rejection, [RangeError: Maximum call stack size exceeded.]
at node_modules/core-js/internals/host-report-errors.js:5:32 in module.exports
at http://127.0.0.1:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false&minify=false:276218:138 in dispatchEvent
at node_modules/core-js/modules/es.promise.js:170:23 in perform$argument_0
at node_modules/core-js/internals/perform.js:3:20 in module.exports
at node_modules/core-js/modules/es.promise.js:167:22 in call$argument_2

Removing the <ToggleStorybook> worked, so I tried to apply @dannyhw patch by 1 - Copying the patch file in that PR to boilerplate/patches/@storybook+addons+5.3.21.patch 2- yarn install 3- expo start -c (-c is to clear the cache)

This seemed to fix the issue even after re-adding the ToggleStorybook 👍 Thanks @dannyhw !

sergioisidoro avatar Mar 17 '22 17:03 sergioisidoro

@jamonholmgren I think maybe this issue could be closed since it looks like its fixed by #1906

dannyhw avatar Mar 17 '22 18:03 dannyhw

Just some info if someone needs storybook and still facing issues: If I remove < ToggleStorybook > as proposed, it works, but thats just a workaround, the real issue is caused because I'm executing my code "too early" in a useEffect() just at the app startup and that has some conflict with storybook initialization (I guess).

If I delay that useEffect() action (in my case I'm launching a mobx action to call the server API inside of It) for example with a TimeOut of 500ms, everything works well.

nesjett avatar Jun 08 '22 02:06 nesjett

Our team has decided to move away from Storybook altogether. We will be removing it in Ignite v8: Maverick. Meanwhile, the reported issue should be resolved with #1906 (thank you!); and for users that prefer not to patch, removing the <ToggleStorybook> wrapper and mounting Storybook inside a navigation screen should achieve similar results.

yulolimum avatar Aug 16 '22 00:08 yulolimum