Skip to content

Conversation

@dingsdax
Copy link
Contributor

@dingsdax dingsdax commented Jan 2, 2026

Add error handling to LoggingHelper methods to fallback to stderr when SDK loggers fail (e.g., JSON formatters with invalid UTF-8 in custom SDK logger). Prevents SDK from crashing while maintaining error visibility.

custom SDK loggers can crash the SDK, we guard against that by returning the exception to stderr
@linear
Copy link

linear bot commented Jan 2, 2026

@dingsdax dingsdax requested review from sl0thentr0py and solnic and removed request for solnic January 2, 2026 17:04
@dingsdax dingsdax changed the title Fix: SDK logger resiliency fix: prevent SDK crash when SDK logging fails Jan 2, 2026
@dingsdax dingsdax marked this pull request as ready for review January 2, 2026 20:51

# @!visibility private
def log_to_stderr(error, message)
$stderr.puts("Sentry SDK logging failed (#{error.class}: #{error.message}): #{message}".scrub(%q(<?>)))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 output stacktrace maybe too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dingsdax yes I think that would be very helpful

Copy link
Collaborator

@solnic solnic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work here! 🚀


# @!visibility private
def log_to_stderr(error, message)
$stderr.puts("Sentry SDK logging failed (#{error.class}: #{error.message}): #{message}".scrub(%q(<?>)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dingsdax yes I think that would be very helpful

Copy link
Member

@sl0thentr0py sl0thentr0py left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ty!

@dingsdax dingsdax merged commit c11a499 into master Jan 5, 2026
136 checks passed
@dingsdax dingsdax deleted the sdk_logger_resiliency branch January 5, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

exception happened in background worker: source sequence is illegal/malformed utf-8

4 participants