Hi, bumping ktor client from 3.4.2 to 3.4.3 causes...
# ktor
o
Hi, bumping ktor client from 3.4.2 to 3.4.3 causes:
Copy code
Error: java.io.IOException: unexpected end of stream on <http://localhost:36389/>...
      │    java.io.IOException: unexpected end of stream on <http://localhost:36389/>...
      │    at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:42)
      │    at io.ktor.client.engine.okhttp.OkHttpEngine.executeHttpRequest(OkHttpEngine.kt:107)
3.4.2 works fine. The renovate pr and run: https://github.com/Trendyol/stove/actions/runs/25662659272/job/75327028874?pr=1167 Is there any breaking change that I might be missing?
a
As I can see, there were no changes to the OkHttp engine between those versions. Does the test fail on each run?
o
It fails yes, not a flaky one. Locally reproducible too
a
Does the test use a local Ktor server?
o
yes
Copy code
fun run(
  args: Array<String>,
  shouldWait: Boolean = false,
  applicationOverrides: () -> Module = { module { } }
): Application {
  val config = loadConfiguration<AppConfiguration>(args)

  val applicationEngine = embeddedServer(Netty, port = config.port, host = "localhost") {
    mainModule(config, applicationOverrides)
  }

  applicationEngine.monitor.subscribe(ApplicationStarted) {
    it.get<ExampleAppConsumer<String, Any>>().start()
  }

  applicationEngine.monitor.subscribe(ApplicationStopping) {
    it.get<ExampleAppConsumer<String, Any>>().stop()
  }

  applicationEngine.start(wait = shouldWait)
  return applicationEngine.application
}
a
The exception might be caused by the fix for KTOR-9343. Can you please try using another server engine to pinpoint the problem?
o
for example CIO?
a
Yes
o
I tried with CIO, locally it passes! Now let’s see what CI thinks. Thanks for the advise
a
Can you please share the steps to reproduce the exception with your project?
b
I've figured out the issue that triggers the connection drops here - running the grpc server on the same JVM as Ktor 3.4.3 with Netty will cause the netty engine to drop all connections. This seems to be the same issue that's causing the problems with the upgrade from Netty 4.2.9 -> 4.2.12 in Ktor.
interesting 1
Looks like it's still an issue in 4.2.13 so we'll need to downgrade back to 4.2.9 in Ktor 3.5.0
o
What if someone forces transitive netty to 4.2.13, it might still appear in a hidden way
b
Yeah, there's a classpath conflict of some sort between Netty > 4.2.9 and Netty 4.1.+ that's referenced from grpc-netty
Looks like it's specifically
netty-codec
that causes the issue, because Ktor depends on
netty-codec-base
so it loads conflicting classes from either jar. A workaround would be:
Copy code
testImplementation("io.grpc:grpc-netty:1.74.0") {
    exclude(group = "io.netty", module = "netty-codec")
  }
Anyway, we should be releasing 3.5.0 this week so I'd recommend just skipping 3.4.3.
o
I was able to bump it with CIO, but as soon as it is released I will bump it to 3.5.0 and release Stove with it, for now it is only in SNASPHOT
Thanks for the investigation!
b
Yeah CIO works, though swapping out the engine could have other hidden implications for consumers. Waiting for 3.5.0 is a good call 👍
I've got a fix with the latest version of Netty too just by depending directly on the codec lib
o
though swapping out the engine could have other hidden implications for consumers.
Exactly 👍
I’ve got a fix with the latest version of Netty too just by depending directly on the codec lib
Is it going to land with 3.5.0 or is it the exclusion above?
b
Yeah, I'll release the fix in 3.5.0
o
Perfect!