0

I have an aura component (as managed package) in service console. the component fetches case's fields (via soql), sends them to an external server, gets a response, and displays it. everything works great until I try to edit a case field. in that case, the page is refreshed together with my component. but in that case, the case info is not shown until my app gets a reply from my server (or gets a timeout). this is weird because when I reload the page, the case info appears before the component finishes its init. As I understand, all js calls to the controller are async, and I also can see the init function ends before I get a reply from the server. So, what might be the problem here? Why is the service console waiting for my component to finish its render?

Thanks in advance!

2 Answers 2

0

Without seeing debug logs, it's hard to tell for sure, but there's at least two possible situations.

First, you could be hitting the browser's six simultaneous connection limit. When too many asynchronous calls occur, one of those calls must finish somehow (timeout, aborted, or completed) before the browser will start a new connection. The order of operations may change depending on how the components load, so this is largely out of your control.

Second, the component could be locking the record while the callout is processing, either by using FOR UPDATE in SOQL, or by performing a DML operation. If the init happens before Lightning Data Service (LDS) can get a fresh copy of the record, then it will be forced to wait until the lock releases. In other words, the component might be forcing synchronicity on you.

Alternatively, it might be a perfect storm of the two situations coming together to prevent the component from loading until the callout completes. This could be really difficult to untangle, especially as a managed package. You may need to talk to the developer of the package to find out exactly what's going on.

A potential fix might be to use force:recordData to load the record via LDS, then perform the callout using that data. Alternatively, maybe you could create a wrapper component to load the managed component after LDS indicates it has loaded the record. This should be easy enough to implement on your own.

1
  • Thanks so much for your answer! Things are getting clearer for me.
    – Jonathan P
    Commented Mar 2, 2021 at 9:23
0

After 1.5 years of investigation, I finally got Salesforce support to look at this issue. It turns out that this behavior is expected!!!! it means that the page will load the viewport first, then wait for all other components to finish loading, and only then will load additional feeds which were not in the viewport. This means that if you have a component with a long processing time, the page will practically be unusable until your app is done or some kind of timeout occurs. SF issued a documentation bug in this issue, it will be added to the next release.

You must log in to answer this question.

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