-
-
Notifications
You must be signed in to change notification settings - Fork 522
fix: prevent SDK crash when SDK logging fails #2817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
custom SDK loggers can crash the SDK, we guard against that by returning the exception to stderr
which might still contain e.g. encoding errors
& simplify test case from GitHub issue #2805
io errors, re-assigment
|
|
||
| # @!visibility private | ||
| def log_to_stderr(error, message) | ||
| $stderr.puts("Sentry SDK logging failed (#{error.class}: #{error.message}): #{message}".scrub(%q(<?>))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 output stacktrace maybe too?
There was a problem hiding this comment.
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
solnic
left a comment
There was a problem hiding this 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(<?>))) |
There was a problem hiding this comment.
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
sl0thentr0py
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ty!
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.