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

.map breaks fresh layers #8858

Closed
hearnadam opened this issue May 14, 2024 · 5 comments
Closed

.map breaks fresh layers #8858

hearnadam opened this issue May 14, 2024 · 5 comments

Comments

@hearnadam
Copy link
Contributor

Minimized reproducer:

  class A
  class B
  val a = ZLayer {
    for {
      _ <- Console.printLine("A")
    } yield new A {}
  }
  val b = ZLayer {
    for {
      _ <- ZIO.service[A]
      _ <- Console.printLine("B")
    } yield new B {}
  }

  def run =
    {
      ZIO.service[A] *> ZIO.service[B]
    }.provide(a.fresh.map(identity), b)

Expectation:

  • A layer maintains its 'freshness' regardless if an operator is invoked on it.
  • Using operators such as .debug should not modify freshness of a layer

Console output:

A
B

Removing the map:

  def run =
    {
      ZIO.service[A] *> ZIO.service[B]
    }.provide(a.fresh, b)

Console output:

A
A
B
@jdegoes
Copy link
Member

jdegoes commented May 15, 2024

/bounty $100 for fix and regression test cases.

Copy link

algora-pbc bot commented May 15, 2024

## 💎 $100 bounty • ZIO

### Steps to solve:
1. Start working: Comment /attempt #8858 with your implementation plan
2. Submit work: Create a pull request including /claim #8858 in the PR body to claim the bounty
3. Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts

Thank you for contributing to zio/zio!

Add a bountyShare on socials

Attempt Started (GMT+0) Solution
🟢 @kpritam May 18, 2024, 12:01:32 AM #8870

@kpritam
Copy link
Contributor

kpritam commented May 18, 2024

/attempt #8858

Algora profile Completed bounties Tech Active attempts Options
@kpritam 1 ZIO bounty
Scala, Makefile,
Kotlin & more
Cancel attempt

Copy link

algora-pbc bot commented May 18, 2024

💡 @kpritam submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented May 19, 2024

🎉🎈 @kpritam has been awarded $100! 🎈🎊

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

No branches or pull requests

3 participants