Skip to content
This repository has been archived by the owner. It is now read-only.

Not working on korolev 1.3.0 + http4s 0.23.12 #429

Open
LMnet opened this issue Jun 20, 2022 · 3 comments
Open

Not working on korolev 1.3.0 + http4s 0.23.12 #429

LMnet opened this issue Jun 20, 2022 · 3 comments

Comments

@LMnet
Copy link

LMnet commented Jun 20, 2022

After updating from this set of dependencies:

val korolev = "1.2.0"
Seq(
  "org.typelevel" %% "cats-effect" % "2.5.1",
  "co.fs2" %% "fs2-core" % "2.5.6",
  "org.http4s" %% "http4s-blaze-server" % "0.21.1",
  "org.fomkin" %% "korolev-ce2" % korolev,
  "org.fomkin" %% "korolev-fs2-ce2" % korolev,
  "org.fomkin" %% "korolev-http4s" % korolev,
  "org.fomkin" %% "korolev-slf4j" % korolev,
)

To this:

val korolev = "1.3.0"
Seq(
  "org.typelevel" %% "cats-effect" % "3.3.12",
  "co.fs2" %% "fs2-core" % "3.2.8",
  "org.http4s" %% "http4s-blaze-server" % "0.23.12",
  "org.fomkin" %% "korolev-ce3" % korolev,
  "org.fomkin" %% "korolev-fs2-ce3" % korolev,
  "org.fomkin" %% "korolev-http4s" % korolev,
  "org.fomkin" %% "korolev-slf4j" % korolev,
)

My korolev application stops working. It loads all static and renders for the first time, but all interactive elements and events are not working.

In server logs I see this:

[INFO ] o.h.b.s.Http1ServerStage$$anon$1   Unknown connection header: 'Upgrade'. Closing connection upon completion.

I tried to investigate a bit. I found that in new version of http4s there is a new way of working with web sockets. WebSocketBuilder is deprecated in favor of WebSocketBuilder2 I tried to fix it locally, but after that my application starts to reload in an infinite cycle. I don't have enough knowledge of korolev internals to dive deeper, so I stopped there.

@morozov11
Copy link
Contributor

morozov11 commented Jun 20, 2022

Korolev gives a normal answer. But here is what I found in WebSocketBuilder2 code:

  private def buildResponse(webSocket: WebSocket[F]): F[Response[F]] =
    onNonWebSocketRequest
      .map(
        _.withAttribute(
          webSocketKey,
          WebSocketContext(
            webSocket,
            headers,
            onHandshakeFailure,
          ),
        )
      )

Wherein

 onNonWebSocketRequest =
        Response[F](Status.NotImplemented).withEntity("This is a WebSocket route.").pure[F],

It turns out that the builder itself immediately gives an error 501 to client.

@LMnet
Copy link
Author

LMnet commented Jun 21, 2022

Looks like this is the root cause: http4s/blaze#659 (comment)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants