question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP/2 response bodies (strict) bigger than 16KiB are not being sent with Ember

See original GitHub issue

As I pointed out in #6842, there seems to a problem with ember when responding with bodies longer than 16KiB. I was able to isolate the issue and it seems to be related exclusively with HTTP/2.

This is a scala-cli file you can use to replicate it:

//> using scala "3.2.0"
//> using lib "org.typelevel::cats-effect:3.4.2"
//> using lib "co.fs2::fs2-core:3.4.0"
//> using lib "co.fs2::fs2-io:3.4.0"
//> using lib "org.http4s::http4s-dsl:1.0.0-M37"
//> using lib "org.http4s::http4s-ember-server:1.0.0-M37"
//> using lib "org.slf4j:slf4j-simple:2.0.5"

import cats.syntax.all.*
import cats.effect.{Async, ExitCode, IO, IOApp, Resource}
import cats.effect.syntax.all.*
import org.http4s.HttpRoutes
import org.http4s.MediaType
import org.http4s.headers.`Content-Type`
import org.http4s.dsl.Http4sDsl
import org.http4s.ember.server.EmberServerBuilder
import com.comcast.ip4s.port

object RunServer extends IOApp with Http4sDsl[IO]:
  private val app = HttpRoutes.of[IO] {
    case GET -> Root / "bytes" / IntVar(numberOfBytes) =>
      val bytes = Array.fill(numberOfBytes)('A'.toByte)

      Ok(bytes).map(_.withContentType(`Content-Type`(MediaType.text.plain)))
  }.orNotFound

  private val server =
    EmberServerBuilder
      .default[IO]
      .withHttpApp(app)
      .withHttp2
      .withPort(port"5000")
      .build

  override def run(args: List[String]): IO[ExitCode] =
    server.useForever

I also uploaded an SBT project where you can check how it behaves with(out) TLS and HTTP/2 in separate services (https://github.com/janilcgarcia/http4s-bug).

Using curl:

curl --http2 localhost:5000/bytes/16384
# result is fine, you get the entire body
curl --http1.1 localhost:5000/bytes/16384
# same

curl --http2 localhost:5000/bytes/16385
# Get headers but no body,
# curl: (18) transfer closed with 16385 bytes remaining to read

curl --http1.1 localhost:5000/bytes/16385
# works ok as well

Libraries/Scala versions are up there. I’ll try to test it ember-server built from source later.

I would love to hlep, but I’d need some pointers to where to look for this bug, I never implemented anything related to an HTTP server before.

I’m on Debian 11 with OpenJDK 17 from the repository, but the same issue happens on Fedora 37 with their OpenJDK 17

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
armanbilgecommented, Dec 3, 2022

@janilcgarcia awesome! Would you mind targeting your PR to the series/0.23 branch? Thanks!

1reaction
janilcgarciacommented, Dec 3, 2022

I’m making a pull request!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · http4s/http4s - GitHub
HTTP/2 response bodies (strict) bigger than 16KiB are not being sent with Ember bug Determined to be a bug in http4s module:ember-server.
Read more >
http4s - Scaladex
Http4s is Scala's answer to Ruby's Rack, Python's WSGI, Haskell's WAI, ... HTTP/2 response bodies (strict) bigger than 16KiB are not being sent...
Read more >
Why doesn't JavaScript have strict greater/less than ...
If the types are not the same, then coercion is attempted. So yes, this answer is still correct in the sense that comparing...
Read more >
Front-End Performance Checklist 2021 (PDF, Apple Pages ...
Is it expensive JavaScript, slow web font delivery, heavy images, or ... In the end, it's not the load events or server response...
Read more >
Falcon Sandbox v8.30 © Hybrid Analysis
https ://falcon.crowdstrike.com/activity/detections/detail/ ... This report is generated from a file or URL submitted to this webservice on November 11th ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found