1

We have a lwc component c-oppty-details which shows opportunity details in a custom way. This includes Record header c-record-home and multiple tabs underneath c-oppty-tabs.

From opportunity main page, we navigate to this custom lwc component via Aura Addressable component which loads this custom component c-oppty-details.

Each time we navigate to this custom component from different opportunity, record home comp getting duplicated. However, if we do full refresh the duplicates go away and correct one shows up.

When we open an opportunity details for first time, all looks correct. enter image description here

But after opening few opportunity details, this is how page looks. As you can see, each time we are navigating to this custom component, it is rendering previous c-record-home as well along with current one the bottom. enter image description here

If we do full page refresh, those duplicate record home comps goes away and it shows the bottom one (which is correct one).

Here is the relevant part of c-oppty-details

<template>
  <c-record-home main-icon="standard:custom_component_task" title="Opportunity Details">
  </c-record-home>
  <lightning-tabset active-tab-value={activeTab} variant="scoped">
    <lightning-tab label={firstTab}>
      <c-oppty-first-tab record-id={recordId}>
      </c-oppty-first-tab>
    </lightning-tab>
    ...more tabs here
  </lightning-tabset>
</template>

Looking at the console, I see below log which seems interesting.

Uncaught (in promise) TypeError: Failed to execute 'removeChild' on 'Node': parameter 1 is not of type 'Node'.
    at DocumentFragment.value [as removeChild] (aura_proddebug.js:2045:27)
    at Object.remove (aura_proddebug.js:11902:14)
    at removeNode (aura_proddebug.js:8949:16)
    at unmount (aura_proddebug.js:8868:11)
    at updateStaticChildren (aura_proddebug.js:9245:23)
    at patchChildren (aura_proddebug.js:8675:11)
    at aura_proddebug.js:10450:11
    at runWithBoundaryProtection (aura_proddebug.js:10770:7)
    at patchShadowRoot (aura_proddebug.js:10443:9)
    at rehydrate (aura_proddebug.js:10426:7)

Question is what could be causing this duplicate record-home comps but rest of the page loads up fine and that duplicate comps goes away if we do full refresh?

5
  • Check the Developer Console (F12) to see if you're getting any errors. That might help us figure out what's going on.
    – sfdcfox
    Commented Nov 23, 2022 at 19:54
  • 1
    Are you using renderedCallback or connectCallback? or any other lwc hook? Commented Nov 23, 2022 at 20:45
  • We are using connectedCallback but not render callback. In the connected callback, we do make api call but we have also has setter for recordId which we re-make the api call to init oppty details.
    – metasync
    Commented Nov 23, 2022 at 22:59
  • @sfdcfox added an error that was shown while navigating second time.
    – metasync
    Commented Nov 23, 2022 at 23:12
  • 1
    I've seen that happen before. Odds are, you have a bug somewhere in the rendering life cycle that's causing the disconnect cycle to break. I had this happen recently with an invalid key for an iterator. Try enabling Lightning Debug Mode (Setup | Debug Mode) and using the "Break on exceptions" and "Break on caught exceptions" feature enabled. You should find a proper error message deep in the stack.
    – sfdcfox
    Commented Nov 23, 2022 at 23:18

1 Answer 1

0

After following the suggestion from @sfdcfox, we found that there was a programming error in disconnectedCallback. Somehow that error was not shown in the console which was resulting in error while cleaning up the nodes (hence the error Failed to execute 'removeChild').

So bottomline is add try/catch to your callbacks and see if have any errors.

3
  • did this solve the problem? also if you answer could mark me? I only receive notifications on marks, I didn't see your answer yesterday, sorry Commented Nov 24, 2022 at 23:40
  • Not sure how to mark you @EliveltonWalter but I upvoted your comment as you alluded to same area.
    – metasync
    Commented Nov 27, 2022 at 6:04
  • 1
    the mark did work, not the upvote, but If I get it right you found out the error adding the try catch? Commented Nov 28, 2022 at 12:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .