You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
withLoggingContextAsync leaves MDC entries on the thread where the block started #607
withLoggingContextAsync writes its entries to the MDC of the current thread. Only then does it switch to withContext(MDCContext()). The body may suspend and resume on another thread. In that case the first thread keeps the entries. The cleanup then writes the previous values onto the second thread.
Unrelated work on either thread then logs with these entries.
runBlocking(Dispatchers.Unconfined) {
withLoggingContextAsync("requestId" to "42") {
withContext(Dispatchers.IO) {} // the body resumes on an IO thread
}
}
println(MDC.get("requestId")) // prints 42
#75 reported the same problem for withLoggingContext and is closed. #597 adds a new function next to the existing one. Fixing withLoggingContextAsync itself is the smaller change. Callers keep their code and get the fix with the next upgrade. I will open a PR for that.
Activity
github-actions commentedon Oct 23, 2026
Thank you for reporting an issue. See the wiki for documentation and slack for questions.