Skip to content
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

Using the Android Studio network inspector crashes the app when performing streaming calls #153

Closed
ln-12 opened this issue Nov 16, 2023 · 4 comments

Comments

@ln-12
Copy link

ln-12 commented Nov 16, 2023

When the network inspector in Android Studio is active while I perform a connect streaming call, the app just crashes with the following error:

E  FATAL EXCEPTION: OkHttp Dispatcher
	Process: com.connectrpc.examples.android, PID: 11743
	java.lang.IllegalStateException: sink already folded
		at okio.Pipe.fold(Pipe.kt:177)
		at com.connectrpc.okhttp.PipeDuplexRequestBody.writeTo(OkHttpStream.kt:211)
		at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:58)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at com.android.tools.profiler.agent.okhttp.OkHttp3Interceptor.intercept(OkHttp3Interceptor.java:57)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at com.android.tools.appinspection.network.okhttp.OkHttp3Interceptor.intercept(OkHttp3Interceptor.kt:52)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at com.android.tools.profiler.agent.okhttp.OkHttp3Interceptor.intercept(OkHttp3Interceptor.java:57)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at com.android.tools.appinspection.network.okhttp.OkHttp3Interceptor.intercept(OkHttp3Interceptor.kt:52)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
		at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
		at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
		at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:517)
		at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
		at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
		at java.lang.Thread.run(Thread.java:1012)

To reproduce, you can simply run the Eliza example from this repo, open the network inspector (wait until it is fully loaded) and open the Connect - bidirectional streaming example. The app crashes immediately with the error above.

@pkwarren
Copy link
Contributor

I believe this is the same underlying issue as https://issuetracker.google.com/issues/235863810.

@ln-12
Copy link
Author

ln-12 commented Nov 17, 2023

Mh, that issue was not updated since over a year... I left a comment there as well as in the linked issue but it seems like that there won't be a solution any time soon.

Maybe the underlying root cause if this issue is the same as in #154?

@pkwarren
Copy link
Contributor

There is nothing to be done at the moment for this issue in connect-kotlin (and it does appear to be the same root cause as #154). Interceptor APIs should be updated to look at the duplex/isOneShot settings of the request body and not consume the body in those cases. See https://github.com/square/okhttp/blob/e92667cf828e58a389a28bd2298ede9957c31ed4/okhttp-logging-interceptor/src/main/kotlin/okhttp3/logging/HttpLoggingInterceptor.kt#L198-L201 for an example of the expected handling.

@ln-12
Copy link
Author

ln-12 commented Dec 1, 2023

Alright, thanks for looking into it.

For reference, here is the related ticket on the google issue tracker: https://issuetracker.google.com/issues/295991498

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

No branches or pull requests

2 participants