jongpie / NebulaLogger

The most robust observability solution for Salesforce experts. Built 100% natively on the platform, and designed to work seamlessly with Apex, Lightning Components, Flow, Process Builder & integrations.
https://nebulalogger.com
MIT License
704 stars 165 forks source link

JavaScript stack traces can still be inaccurate due to createLogger() being async #728

Closed jongpie closed 3 weeks ago

jongpie commented 2 months ago

For some browsers + contexts, JS stack traces are missing info need to determine a JS log entry's origin details. This includes using async connectedCallback()

I'd like to explore 2 options:

  1. Find a way to make createLogger() no longer async without causing issues in existing code
  2. Keep createLogger() async, but introduce another function that isn't async - createLogger() would then be considered deprecated, but still supported for now
jamessimone commented 2 months ago

I can play around with the demo aura component - I think there's probably a way to keep the existing API while improving the experience for aura consumers

jongpie commented 2 months ago

@jamessimone yeah if you have some time to look into this, that'd be great! But I don't think it's just aura components - I'm wrapping up some testing for #727 now, and I'm seeing this issue also happening when using importing createLogger().

MS Edge

This screenshot is from MS Edge (but I think happens in Chrome too). The functionName shows as just eval, and the phrase connectedCallback doesn't appear anywhere in the original stack from new Error().stack

image

Original stack value:

   Error
    at LoggerService._newEntry (modules/c/logger.js:651:60)
    at LoggerService.info (modules/c/logger.js:585:21)
    at eval (modules/c/loggerLWCImportDemo.js:207:26)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (modules/c/loggerLWCImportDemo.js:183:107)
    at _next (modules/c/loggerLWCImportDemo.js:184:198)
    at eval (eval at <anonymous> (https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:37361:87), <anonymous>:2536:24)
    at BoundaryProxyHandler$LWS.applyOrConstructTrapForOneOrMoreArgs$LWS (https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:34172:38)

Firefox

In Firefox, its stack traces seem to work fine (they're also HUGE compared to MS Edge) - the original value from new Error().stack contains connectedCallback, which ends up getting parsed as the functionName

image

Original stack value:

_newEntry@modules/c/logger.js:651:60
finest@modules/c/logger.js:585:21
connectedCallback/<@modules/c/loggerLWCImportDemo.js:207:26
asyncGeneratorStep@modules/c/loggerLWCImportDemo.js:183:107
_next@modules/c/loggerLWCImportDemo.js:184:216
createHooksCallback$LWS/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js line 37361 > eval:2536:24
applyOrConstructTrapForOneOrMoreArgs$LWS@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:34172:38
Async*createHooksCallback$LWS/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:36000:24
applyOrConstructTrapForTwoOrMoreArgs$LWS@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js line 37361 > eval:763:38
asyncGeneratorStep@modules/c/loggerLWCImportDemo.js:183:246
_next@modules/c/loggerLWCImportDemo.js:184:216
_asyncToGenerator/</<@modules/c/loggerLWCImportDemo.js:184:373
createHooksCallback$LWS/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js line 37361 > eval:2536:24
applyOrConstructTrapForTwoOrMoreArgs$LWS@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:34227:38
createHooksCallback$LWS/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:36034:24
applyOrConstructTrapForOneOrMoreArgs$LWS@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js line 37361 > eval:708:38
_asyncToGenerator/<@modules/c/loggerLWCImportDemo.js:184:101
connectedCallback@modules/c/loggerLWCImportDemo.js:215:11
createHooksCallback$LWS/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js line 37361 > eval:2536:24
applyOrConstructTrapForTwoOrMoreArgs$LWS@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:34227:38
callHook@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10703:19
invokeComponentCallback/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10520:21
runWithBoundaryProtection@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11214:13
invokeComponentCallback@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10519:34
runConnectedCallback@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11063:36
mountCustomElement@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9041:41
mount@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8916:35
updateStaticChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9597:26
patchChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8850:33
patchElement@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8981:22
patch@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8886:29
updateStaticChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9581:34
patchChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8850:33
patchShadowRoot/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10998:34
runWithBoundaryProtection@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11214:13
patchShadowRoot@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10993:42
rehydrate@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10980:28
flushRehydrationQueue@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11032:26
flushCallbackQueue@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:5299:25
promise callback*addCallbackToNextTick@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:5310:31
scheduleRehydration@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11197:34
getTemplateReactiveObserver/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10643:36
notify@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:5251:27
valueMutated@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:5177:24
componentValueMutated@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:5265:25
updateComponentValue@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:5689:34
set@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:6794:37
connectedCallback/<@https://site-connect-8813.scratch.lightning.force.com/components/flowruntime/lwcField.js:183:15
promise callback*connectedCallback@https://site-connect-8813.scratch.lightning.force.com/components/flowruntime/lwcField.js:181:48
callHook@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10703:19
invokeComponentCallback/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10520:21
runWithBoundaryProtection@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11214:13
invokeComponentCallback@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10519:34
runConnectedCallback@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11063:36
mountCustomElement@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9041:41
mount@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8916:35
mountVNodes@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9104:22
updateStaticChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9561:24
patchChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8850:33
patchShadowRoot/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10998:34
runWithBoundaryProtection@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11214:13
patchShadowRoot@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10993:42
rehydrate@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10980:28
appendVM@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10731:18
mountCustomElement@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9047:21
mount@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8916:35
mountVNodes@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9104:22
mountElement@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8969:20
mount@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8912:29
mountVNodes@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9104:22
updateStaticChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9561:24
patchChildren@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:8850:33
patchShadowRoot/<@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10998:34
runWithBoundaryProtection@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:11214:13
patchShadowRoot@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10993:42
rehydrate@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10980:28
appendVM@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:10731:18
mountCustomElement@https://static.lightning.force.com/cs171/auraFW/javascript/eGx3MHlRT1lEMUpQaWVxbGRUM1h0Z2hZX25NdHFVdGpDN3BnWlROY1ZGT3cyNTAuOC4zLTYuNC41/aura_proddebug.js:9047:21
aura_proddebug.js:36000:24
jongpie commented 3 weeks ago

This has been fixed in release v4.14.13 via a new getLogger() sync function. The function createLogger() is still supported & functional, but it's now considered deprecated since it requires using await (which is no longer necessary with getLogger())