When the library emits a log to try and help the user diagnose or resolve an issue, we usually include a stack trace in order to provide them with a location to start the investigation.
More often than not, however, this stack trace is loaded with internal calls, flowing in and out of async, or other calls in the user's application.
On every entrypoint via userland code, we should store a stack trace ahead of time, such that any logs emitted to users via prettyError() can be attributed to those traces instead of our internal ones.
Summary
When the library emits a log to try and help the user diagnose or resolve an issue, we usually include a stack trace in order to provide them with a location to start the investigation.
More often than not, however, this stack trace is loaded with internal calls, flowing in and out of async, or other calls in the user's application.
On every entrypoint via userland code, we should store a stack trace ahead of time, such that any logs emitted to users via
prettyError()
can be attributed to those traces instead of our internal ones.