Skip to content

catching Throwables in RealEventSource #8735

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

Closed
wants to merge 1 commit into from

Conversation

MukjepScarlet
Copy link
Contributor

closes #8463

@MukjepScarlet
Copy link
Contributor Author

Defination of listener.onFailure:

public open fun onFailure(
    eventSource: EventSource,
    t: Throwable?,
    response: Response?
): Unit

@@ -80,7 +80,7 @@ internal class RealEventSource(
while (!canceled && reader.processNextEvent()) {
}
}
} catch (e: Exception) {
} catch (e: Throwable) {

Choose a reason for hiding this comment

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

Is there a reason we want to catch/handle something we cannot recover from, such as an OutOfMemoryError.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the onFailure will re-throw it, with param of Throwable? instead of Exception?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I responded on the original bug, I don't think we should be surfacing these as if the app can handle and continue. The state of OkHttpClient is probably unknown at this point.

@yschimke yschimke closed this May 4, 2025
@MukjepScarlet MukjepScarlet deleted the patch-1 branch May 4, 2025 12:13
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.

RealEventSource lost control on Error
3 participants