lovelace-auto-entities icon indicating copy to clipboard operation
lovelace-auto-entities copied to clipboard

Race condition causes unreliable behavior with custom container cards

Open mag1024 opened this issue 2 years ago • 1 comments

I believe there is a race condition in auto-entities code that causes it to behave unreliably (to occasionally fail to load and just display a blank card) especially with custom container cards, presumably because they are slower to load. This issue is likely the root cause of piitaya/lovelace-mushroom#698 and #286.

It appears that that is a lack on synchronization to wait for the container card to finish loading before we start adding entities to it. Specifically, I have observed that adding a "sleep" (await new Promise(r => setTimeout(r, 200));) before this line appears to work around the problem, although I don't know enough about JS to know what the proper fix is.

mag1024 avatar Sep 05 '22 04:09 mag1024

This comment by @jcwillox (thanks, Josh!) might have some clues as per the real cause.

mag1024 avatar Sep 05 '22 04:09 mag1024