-
Couldn't load subscription status.
- Fork 1.4k
Implement ZIO#forkInternal to Prevent Spurious Warnings #1949
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
Conversation
| mapM(f andThen UIO.succeed) | ||
|
|
||
| /** | ||
| * Effectually maps over the favlue the fiber computes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed now.
| * Forks an effect that will be executed without unhandled failures being | ||
| * reported. This is useful for implementing combinators that handle failures | ||
| * themselves. | ||
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for doc
| /** | ||
| * Traverses the `Exit` with an effectual function. | ||
| */ | ||
| def traverse[R, E1 >: E, B](f: A => ZIO[R, E1, B]): ZIO[R, Nothing, Exit[E1, B]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Let's add foreach alias too, if it doesn't exist.
| * themselves. | ||
| */ | ||
| private[zio] final def forkInternal: ZIO[R, Nothing, Fiber[E, A]] = | ||
| run.fork.map(_.mapM(IO.done)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
* implement forkInternal * fix typo * add foreach alias
* implement forkInternal * fix typo * add foreach alias
Currently we generate a lot of spurious fiber failure warnings. For example, consider:
This will succeed because
foldCauserecovers from all errors. But a fiber failure warning will still be printed to the console because one of the forked fibers inraceWith, whichzipParis implemented in terms of, ended in failure. This is undesirable in general and particularly confusing to new users who don't understand why the warning is displayed or that the success of their effect is independent of this warning.This PR implements a new combinator
forkInternalthat forks an effect that will be executed without unhandled failures being reported. This can be use in combinators such asraceWiththat implement their own logic for handling failures to avoid these spurious warnings being generated.So far I have only used this in
raceWith, which seems to be the cause of most of the spurious warnings that are being reported, but we should be able to use this in other combinators as well.