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

Update to zio 2.1.x for sttp 3.9.x #2243

Closed
dlagnohed opened this issue Aug 5, 2024 · 5 comments
Closed

Update to zio 2.1.x for sttp 3.9.x #2243

dlagnohed opened this issue Aug 5, 2024 · 5 comments

Comments

@dlagnohed
Copy link

dlagnohed commented Aug 5, 2024

In order to run sttp with the latest zio version, a new release is necessary.
This issue affects the sttp3-branch branch.

@adamw
Copy link
Member

adamw commented Aug 5, 2024

Can you create a PR against the sttp3 branch?

@dlagnohed
Copy link
Author

I'm not sure if there's another way to do this besides commenting in the issue description.

@adamw
Copy link
Member

adamw commented Aug 5, 2024

I meant a PR such as: #2244
Let's see if the tests pass

@adamw
Copy link
Member

adamw commented Aug 5, 2024

Unfortunately after update the Scala 3 version starts failing with:

[error] -- [E172] Type Error: /home/runner/work/sttp/sttp/effects/zio/src/main/scalajvm/sttp/client3/httpclient/zio/HttpClientZioBackend.scala:162:5 
[error] 162 |    )
[error]     |     ^
[error]     |could not find implicit value for izumi.reflect.Tag[sttp.client3.SttpBackend[zio.Task, sttp.capabilities.zio².ZioStreams &
[error]     |  sttp.capabilities.WebSockets]]. Did you forget to put on a Tag, TagK or TagKK context bound on one of the parameters in sttp.client3.SttpBackend[zio.Task, sttp.capabilities.zio².ZioStreams &
[error]     |  sttp.capabilities.WebSockets]? e.g. def x[T: Tag, F[_]: TagK] = ....
[error]     |I found:
[error]     |
[error]     |    zio.Tag.materialize[
[error]     |      
[error]     |        sttp.client3.SttpBackend[zio.Task, sttp.capabilities.zio².ZioStreams &
[error]     |          sttp.capabilities.WebSockets]
[error]     |      
[error]     |    ]
[error]     |
[error]     |But method materialize in trait TagVersionSpecific does not match type zio.Tag[
[error]     |  sttp.client3.SttpBackend[zio.Task, sttp.capabilities.zio².ZioStreams &
[error]     |    sttp.capabilities.WebSockets]
[error]     |]
[error]     |
[error]     |where:    zio  is a package
[error]     |          zio² is a package in package sttp.capabilities
[error]     |.

After providing the tag explicitly in HttpClientZioBackend:162:

ZLayer.scoped.apply(
      (for {
        backend <- HttpClientZioBackend(
          options,
          customizeRequest,
          customEncodingHandler
        )
      } yield backend).tap(client => ZIO.addFinalizer(client.close().ignore))
    )(zio.Tag.materialize[SttpBackend[Task, ZioStreams with WebSockets]])

I get:

[error] 162 |    )(zio.Tag.materialize[SttpBackend[Task, ZioStreams with WebSockets]])
[error]     |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]     |You must not use an intersection type, yet have provided sttp.capabilities.zio.ZioStreams & sttp.capabilities.WebSockets

However this doesn't offer any solutions to the problem, just that the intersection type might be the cause for the original compiler failure.

Something must have changed between ZIO 2.0 and 2.1, but I think somebody with deeper ZIO knowledge would have to help with this one.

@adamw
Copy link
Member

adamw commented Oct 2, 2024

I'll try with an ugly hack:

  // work-around for "You must not use an intersection type, yet have provided SttpBackend[Task, ZioStreams & WebSockets]", #2244
  implicit val sttpClientTag: Tag[SttpClient] =
    Tag.materialize[SttpBackend[Task, ZioStreams]].asInstanceOf[Tag[SttpClient]]

works in tests :)

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