Repository navigation
Android crash when network changes from Good to Bad #10423
Description
Issue Description
When there are fetch requests made on Android and the network changes from a good connection to a very bad connection, sometimes a crash occurs in RealBufferedSink.java:39.
Steps to Reproduce / Code Snippets
- Make constant fetch requests (Once every couple of seconds)
- Switch between a good network connection and a very bad one (if an iPhone is available it can be used as a hotspot for the Android device and can switch between LTE and very Bad Network)
Switching between the networks should reproduce the problem fairly quickly.
Expected Results
The error:
java.lang.IllegalStateException: closed
at okio.RealBufferedSink.write(RealBufferedSink.java:39)
at okio.ForwardingSink.write(ForwardingSink.java:35)
at com.facebook.react.modules.network.ProgressRequestBody$1.write(ProgressRequestBody.java:58)
at okio.RealBufferedSink.flush(RealBufferedSink.java:216)
at com.facebook.react.modules.network.ProgressRequestBody.writeTo(ProgressRequestBody.java:48)
at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.java:47)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
at okhttp3.RealCall.access$100(RealCall.java:33)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Additional Information
- React Native version: 0.41.0 (All previous version also have this issue)
- Platform(s) (iOS, Android, or both?): Android
- Operating System (macOS, Linux, or Windows?): macOS
Activity
saleehk commentedon Nov 4, 2016
@armadilio3 Same issue here. did you got that fixed .?
armands-malejevs commentedon Nov 7, 2016
@saleeh93 still looking into it, maybe you could describe how you can replicate the crash since I am working on a fairly large project and I am only beginning to pinpoint the exact place of origin for this bug
saleehk commentedon Nov 7, 2016
@armadilio3 I am also working on large project and I never had that issue when I am testing it, I got those errors from Crashlytics. I didn't even understand when that is coming up
saleehk commentedon Dec 9, 2016
@armadilio3 Any updates ?
LucasSouzaa commentedon Feb 10, 2017
Same issue here :(
saleehk commentedon Feb 10, 2017
@lucasfeliciano Still waiting to get this fixed
armands-malejevs commentedon Mar 10, 2017
So, I have found a temporary solution to this problem which is based on catching the error. After some testing it seems that if you catch the OkHttp error the network request will fail but the app won't crash. So if anyone is interested here is the temporary solution:
Edit your MainApplication.java
When I have the time I will look into the root cause of this issue as this is a very poor fix. If I find a solution, will make PR.
saleehk commentedon Mar 11, 2017
@armadilio3 You are tricky 😉
yunlongz commentedon Mar 17, 2017
@armadilio3 I use yours,but It`s not running.
LucasSouzaa commentedon Mar 17, 2017
@yunlongz are you building from source?
I use this "solution" and work fine.
abrantes01 commentedon Apr 18, 2017
@armadilio3's solution works fine for me. But does anyone have any news on this problem?
Tekosawa commentedon Jul 7, 2017
Anyone found a real fix ? Problem still exist.
loiclouvet commentedon Aug 16, 2017
I tried @armadilio3 issue but I still have same crashes (maybe because I use react-native-fabric).
22 remaining items
stale commentedon Aug 14, 2018
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.
Android. OkHttp crash fixed on upload re-try. (#20802)
kelset commentedon Aug 23, 2018
(quick update, we merged a fix for it and we'll probably cherry pick for 0.57-rc3)
Android. OkHttp crash fixed on upload re-try. (#20802)
Android. OkHttp crash fixed on upload re-try. (react#20802)
stale commentedon Nov 22, 2018
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.
stale commentedon Nov 29, 2018
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.