RuntimeException thrown in interceptor never notifies Call
See original GitHub issueIf an okhttp3.Interceptor throws an exception, the suspend function in a Retrofit interface never completes (neither returning a value or throwing an exception).
A sample project demonstrating the issue with a simple JUnit test can be found here: https://github.com/robfletcher/retrofit-coroutines-hang
The real situation when I’ve encountered this is when an SSL handshake fails.
FWIW the same behavior is seen using https://github.com/JakeWharton/retrofit2-kotlin-coroutines-adapter with Retrofit 2.5.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Handle exceptions thrown by a custom okhttp Interceptor in ...
Actually coroutine's suspend functions throws exception when dealing with network calls. In my experience, you can follow 2 approaches. 1. wrap ...
Read more >Class PersistenceExceptionTranslationInterceptor - Spring
Delegates to the given PersistenceExceptionTranslator to translate a RuntimeException thrown into Spring's DataAccessException hierarchy (if appropriate).
Read more >TransactionalException (Java(TM) EE 7 Specification APIs)
public class TransactionalException extends RuntimeException. The TransactionalException thrown from the Transactional interceptors implementation contains ...
Read more >3. Resolved and Known Issues Red Hat JBoss Enterprise ...
ERROR [org.jboss.remoting.handler-errors] Close handler threw an exception: ... The channel is now closed when Context.close() is called, even if other ...
Read more >Map - Hazelcast Documentation
ConcurrentMap operations never throw a java.util. ... it is propagated to the original IMap.put() or IMap.remove() call in the form of RuntimeException ....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just adding a workaround here in case it helps. Actually in my case even IOExceptions are not propagating back. Retrofit 2.6.2, okhttp 4.2.0
I wanted to deal with this at point of call rather than add an UncaughtExceptionHandler.
So the workaround was to add an interceptor which catches any IOExceptions, and returns a blank response with a magic status code.
This could be combined with a Result object like in the answer here: https://stackoverflow.com/questions/57625272/retrofit-2-6-0-custom-coroutines-calladapterfactory where the status code or message is checked and a NetworkError returned.
Hi @robfletcher, are there any updates on this issue?