-
When using the newer version of the LWC Logger pattern I am unable to successfully create an Error Log in the Connected Callback cycle. I have included the
and
This is meant to simulate an error, catch the error, display the LWC error component, and generate a Log. Everything works except the Log is not created. Does the saveLog() method need something additional? The Demo recipe works fine but is geared towards User interaction (pushing buttons). I am trying to model what would happen if the LWC completely fails.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
UPDATE I was able to determine that the saveLog() was actually being executed prior to the logger actually finishing its creation. I did this on the wire call which returned a forced Error from the Apex controller. I added a setTimeout method that paused the saveLog() for 2.5 seconds after the logger creation was initiated. This resulted in the Log (error) being created without issue. I am still interested in knowing if there is a delivered solution that I may have overlooked.
|
Beta Was this translation helpful? Give feedback.
Hi @shuylern, thanks for doing some investigation on this! It sounds like a bug in the new
createLogger()
function - adding new entries happens asynchronously, but thesaveLog()
function runs synchronously, so in lifecycle events likeconnectedCallback()
, saving seems to be problematic. ThesaveLog()
function inlogger
needs to be enqueued so it runs after adding entries.I've made a bug for this, #518 - I'll see if there's a quick & effective way to get this resolved in the coming weeks.