-
Notifications
You must be signed in to change notification settings - Fork 657
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
How to properly close shutdown an apollo client version 3? #3802
Comments
Hi 👋 You can use |
My bad, looks like there's a regression there that keeps a thread open. Will keep looking and update this thread. |
Indeed, this should be fixed with #3803. Sorry about this. Until next version, you can set a no-op ApolloClient.Builder()
.serverUrl("https://www.google.com")
.okHttpClient(okHttpClient)
.subscriptionNetworkTransport(object: NetworkTransport {
override fun dispose() {
}
override fun <D : Operation.Data> execute(request: ApolloRequest<D>): Flow<ApolloResponse<D>> {
TODO("Not yet implemented")
}
}) |
Thanks for validating. That led to |
ooops, my bad. val apolloClient = ApolloClient.Builder()
.serverUrl("https://www.google.com")
.httpEngine(DefaultHttpEngine(okHttpClient))
.subscriptionNetworkTransport(object : NetworkTransport {
override fun dispose() {
}
override fun <D : Operation.Data> execute(request: ApolloRequest<D>): Flow<ApolloResponse<D>> {
TODO("Not yet implemented")
}
})
.build() |
With version 3 a simple fun main with a runBlocking calling a query execute will continue to run and not exit. When commenting out the Apollo code the main exits and process exits. Thanks for the help.
Note: This didn't help
https://github.com/martinbonnin/termination-test/blob/main/src/main/kotlin/com/example/Main.kt
and I am not sure how it worked since the below
okHttpClient.dispatcher().executorService().shutdown()
for me is
okHttpClient.dispatcher.executorService.shutdown()
The only different thing I've done besides that code there, is the okHttpClient and apolloClient are defined outside the fun main like the apollo version 3 docs suggests apolloClient is a top-level variable.
The text was updated successfully, but these errors were encountered: