4

I am working on one AppExchange app on Salesforce Lightning. I have successfully completed development of that app. But while testing, found one very weird issue. Please check following issue,

Issue: Invalid component tried calling function [get] with arguments [v.items.7], markup://aura:iteration [54407:c]

Conditions on which issue occurs: - When we start app, it work correctly and gives correct output.

  • But after some time, if we click on any button or link, this error pop's up on screen.

  • But one weird behaviour of this error is, app works correctly and gives expected output in background.

  • Please check attached screen shot of the error I got.

enter image description here

Can anyone please help me on this issue?

Thanks in advance.

5
  • Please update the question and post some of your code related to this error. Aug 8 '15 at 5:51
  • @Bachovski: Thanks for your reply. This error is not occurring on any specific line of code. Code is working fine in background, just this error is coming as a popup. This error is not affecting any functionality. Aug 8 '15 at 5:56
  • Any solution for this problem!?? Jul 11 '16 at 11:20
  • @SuryaChandraRaoGandreddi: We reported this issue to Salesforce and also made some changes to code (mainly optimization) to solve this issue. We never faced this issue after that again. One quick question though, are you using any JS MVC liabrary on top of lightning? Jul 13 '16 at 3:57
  • Thanks @TusharKumawat. No we're not using any third party JS libraries. It is Pure lightning. If I may ask, what are the changes you made to make it working, any suggestions for me. Thank you once again. Jul 13 '16 at 11:54
0

So this ones going to be tricky. The component that contains the iteration is being unrendered, and in the same process the iteration is trying to rerender. This actually sounds like an issue in aura:iteration, so you'll probably want to file a bug.

That probably doesn't help you for several months though, so in the mean time, you can try to get a reference to your component, and then do the following.

var iteration = cmp.find("yourIterationId");
iteration.autoDestroy(false);

The problem with this, is that you now have a leaky component. It'll never be destroyed, it just stays around, but till the issue is solved, at least your code should work.

5
  • Thanks for looking into this. I tried the solution provided by you, but aura:iteration doesn't support "ID" as an attribute. Is there any other way we can select aura components? Aug 10 '15 at 9:28
  • It supports aura:id
    – Kris Gray
    Aug 10 '15 at 13:33
  • I followed the sample code you have provided but I am getting following error, Error: AuraClientService.popStack(): Failed during processing : iteration.autoDestroy is not a function. I searched about autoDestroy function but didn't found any reference related to it in any documentation. Can you please suggest any other way to prevent this? Aug 11 '15 at 5:54
  • It appears if I do .autoDestroy(false) within a component being used on record home, the component is removed from the record home layout? Any other ideas on how to avoid this situation? Sep 5 '15 at 14:29
  • Ok, it was just throwing an exception on init that apparently stripped the component. Now if I run that after init I also get autoDestroy is not a function :| Sep 5 '15 at 14:40
0

Your problem is probably related to the same issue that we have experienced.

ISSUE

When you start your app, your components are rendered on the screen. As you use the app, new components might be rendered on the screen instead of the previous ones. Let's say you render calendar events components on a calendar. As you change dates, new calendar events are rendered and the previous ones deleted.

The problem is that the previous components are not really deleted, the app still sees them but they are not rendered on the screen. If you try to access any attributes of not rendered component it will throw a similar exception to yours.

SOLUTION

Before you try to access attributes of any components that might disappear over the time your app is being used, call:

if(!component.isRendered()){
   return;
}

This would ensure that you are not trying to perform any work on not rendered components.

This solution doesn't have any memory leaks and works very well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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