Skip to main content
Answered

[react-native] removing event listener throws "Maximum call stack size exceeded" error

  • January 11, 2023
  • 8 replies
  • 1261 views

Howdy!

We're experiencing this issue after updating from 3.x SDK to 4.0.1 (https://github.com/intercom/intercom-react-native

 

react-native version: 0.70.5

 

 

Code sample (which is basically the same that you have in docs):

 

useEffect(() => {
const subscription = Intercom.addEventListener(
IntercomEvents.IntercomUnreadCountDidChange,
(response) => {
setCount(response.count);
}
);
 
return () => {
try {
subscription.remove();
} catch (e) {
console.log(e);
}
};
}, []);

 

Calling subscription.remove on line 11 during effect cleanup triggers an exception.

Line 13 prints:

[RangeError: Maximum call stack size exceeded]

Without try/catch block the call just fails silently due to this - https://github.com/facebook/react-native/issues/32673(which doesn't contribute to the original problem, just makes it go unnoticed).

 

 

Let me know what other details you might need.

 

What can be done about it? Thanks.

Best answer by aykut.aydin

Hey everyone!

 

Just wanted to leave a reply here in case anyone is still experiencing this issue. The issue was resolved as the PR here was merged. If you use a version 5.0.0 or newer, you will not experience this issue any longer.

View original
Did this topic help you find an answer to your question?

8 replies

Diana Tripac
Intercom Team
Forum|alt.badge.img+2
  • Senior Community Program Manager @Intercom
  • 154 replies
  • January 13, 2023

Looping in @user1207​  in case he has any ideas on that 🙌


Oseas
Employee
Forum|alt.badge.img+4
  • Employee
  • 103 replies
  • January 16, 2023

Hey @alex t​! Oséas here from the Customer Support Engineering team 🕵️

 

I've opened a bug report on our end for this issue so our Product Team can investigate this further. Could you please reach out to us via the Messenger so we can add the conversation to the report and, if necessary, request more info? Make sure to mention this thread when opening the conversation so my teammate who will get the convo knows which issue to link. Once we add it, any updates made will generate an internal notification in the convo and we'll be able to notify you.

 

Thank you very much for flagging this to us - really appreciate it!


  • Author
  • New Participant
  • 1 reply
  • January 17, 2023

Thank you, I will


  • New Participant
  • 3 replies
  • February 28, 2023

We are experiencing the the exact same issue since updating to 4.0.1, we are using react-native. And it seems the crash only occurs when running android in debug mode and the component that has the subscription cleanup, dismounts. Not entirely sure yet if it's affecting the app in production. Ios seems to have no problems.


We are encountering the same issue: removing the subscription to the unread message count throws an error:

ERROR  Warning: Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Likely causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer.

Error message:

RangeError: Maximum call stack size exceeded.

For us it’s happening on iOS, both in the simulator and on device. RN 0.68, Intercom 4.0.1.


Forum|alt.badge.img
  • Connector
  • 6 replies
  • May 15, 2023

Any update on this issue? It’s marked as solved, but it doesn’t look solved!


  • New Participant
  • 3 replies
  • May 23, 2023
Samuel B wrote:

Any update on this issue? It’s marked as solved, but it doesn’t look solved!

I have yet to try it myself, but it does look like they have merged a pull request that fixes the infite loop issue in their latest release of react-native (5.0.0).


aykut.aydin
Employee
Forum|alt.badge.img+4
  • Customer Support Engineer
  • 104 replies
  • Answer
  • October 6, 2023

Hey everyone!

 

Just wanted to leave a reply here in case anyone is still experiencing this issue. The issue was resolved as the PR here was merged. If you use a version 5.0.0 or newer, you will not experience this issue any longer.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings