Version
1.0-RC1+14-a287ac73+20250724-1908-SNAPSHOT
Scala Version
3.7.1
Expected Behavior
When a stream is defined using an Emit[Chunk] effect wrapped in Sync.ensure or Scope.ensure, and then the stream is run using .take the finalizer should run.
Actual Behavior
The finalizer does not run
Steps to Reproduce
Run the following tests:
"Sync.ensure" - {
"take" in run {
for
ref <- AtomicRef.init(List.empty[String])
stream = Stream:
Sync.ensure(ref.getAndUpdate("finalized" :: _)):
Loop(0)(i => ref.getAndUpdate(i.toString :: _).andThen(Emit.valueWith(Chunk(i))(Loop.continue(i + 1))))
emittedValues <- stream.take(5).run
refValues <- ref.get
yield assert(emittedValues == Chunk(0, 1, 2, 3, 4) && refValues == List("finalized", "4", "3", "2", "1", "0"))
}
}
"Scope.ensure" - {
"take" in run {
for
ref <- AtomicRef.init(List.empty[String])
stream = Stream:
Scope.run:
Scope.ensure(ref.getAndUpdate("finalized" :: _)).andThen:
Loop(0)(i => ref.getAndUpdate(i.toString :: _).andThen(Emit.valueWith(Chunk(i))(Loop.continue(i + 1))))
emittedValues <- stream.take(5).run
refValues <- ref.get
yield assert(emittedValues == Chunk(0, 1, 2, 3, 4) && refValues == List("finalized", "4", "3", "2", "1", "0"))
}
}
Current Workaround
No response
Version
1.0-RC1+14-a287ac73+20250724-1908-SNAPSHOT
Scala Version
3.7.1
Expected Behavior
When a stream is defined using an
Emit[Chunk]effect wrapped inSync.ensureorScope.ensure, and then the stream is run using.takethe finalizer should run.Actual Behavior
The finalizer does not run
Steps to Reproduce
Run the following tests:
Current Workaround
No response