fix: stop the diagnostic logger from throwing while logging - #2832
Open
bitsandfoxes wants to merge 2 commits into
Open
fix: stop the diagnostic logger from throwing while logging#2832bitsandfoxes wants to merge 2 commits into
bitsandfoxes wants to merge 2 commits into
Conversation
Callers log from inside catch blocks that have already handled the failure. UnityLogger interpolated the exception directly, so anything that threw while being stringified escaped from within the handler and turned a handled error into a fatal one. On Nintendo Switch that is what happened: with DisableFileWrite set, resolving the installation ID falls through to NetworkInterface.GetAllNetworkInterfaces(), whose static initializer throws. Hub.ConfigureScope caught it and logged it, but stringifying that exception threw again, escaping the handler and aborting SDK initialization partway through registering integrations. Every Unity integration after GlobalRootScopeIntegration was left unregistered, so nothing was captured and no envelope was ever produced. Format the message and render the exception defensively, falling back to the type and message when the stack trace cannot be read, and never let the write to Unity's logger propagate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ABHTqM37qGAc9iQZcdbdY8
bitsandfoxes
force-pushed
the
fix/unity-logger-throws-while-logging
branch
from
September 4, 2026 11:54
7eb12b5 to
023e5d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
A diagnostic logger must never take its caller down with it. I.e. when logging from inside a
catchthat has already handled the failure. Throwing inside the catch because logging? You're in for a bad time.UnityLogger.Loginterpolated the exception directly:So anything that threw while being stringified escaped from within the handler.
The fix
Format the message and render the exception defensively, and never let the write to Unity's logger propagate. The exception falls back to type and message when the stack trace cannot be read, so the error stays legible instead of disappearing.
Example: