Repository navigation
#4505 Not Propagating Fatal Errors #4678
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
base: series/3.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,7 +53,7 @@ package examples { | |||||||||||||||
|
|
||||||||||||||||
| object FatalErrorRaw extends RawApp { | ||||||||||||||||
| def main(args: Array[String]): Unit = { | ||||||||||||||||
| import cats.effect.unsafe.implicits._ | ||||||||||||||||
| import cats.effect.unsafe.implicits.* | ||||||||||||||||
| val action = | ||||||||||||||||
| IO(throw new OutOfMemoryError("Boom!")).attempt.flatMap(_ => IO.println("sadness")) | ||||||||||||||||
| action.unsafeToFuture() | ||||||||||||||||
|
|
@@ -131,6 +131,16 @@ package examples { | |||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| object AsyncFatalError extends IOApp { | ||||||||||||||||
| def run(args: List[String]): IO[ExitCode] = { | ||||||||||||||||
| IO.async_[Unit](cb => cb(Left(new OutOfMemoryError("Boom!")))) | ||||||||||||||||
| .start | ||||||||||||||||
| .flatMap(_.join) | ||||||||||||||||
| .flatMap(_ => IO.println("sadness")) | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original reproducer in #4505 runs the async on a fiber and joins it: _ <- pingFiber.join
} yield ExitCode.Success
The core issue with #4505 is that the code shouldn't even get far enough that there is a join result, as the OOM should kill the app immediately. You can probably reproduce this with just an attempt instead of a start/join
Suggested change
or to more closely replicate the original, something like:
Suggested change
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Applied the second change here, it made the test red: ec8421b Thanks! |
||||||||||||||||
| .as(ExitCode.Success) | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| object Canceled extends IOApp { | ||||||||||||||||
| def run(args: List[String]): IO[ExitCode] = | ||||||||||||||||
| IO.canceled.as(ExitCode.Success) | ||||||||||||||||
|
|
@@ -171,7 +181,7 @@ package examples { | |||||||||||||||
|
|
||||||||||||||||
| object LiveFiberSnapshot extends IOApp.Simple { | ||||||||||||||||
|
|
||||||||||||||||
| import scala.concurrent.duration._ | ||||||||||||||||
| import scala.concurrent.duration.* | ||||||||||||||||
|
|
||||||||||||||||
| lazy val loop: IO[Unit] = | ||||||||||||||||
| IO.unit.map(_ => ()) >> | ||||||||||||||||
|
|
||||||||||||||||
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.
Is there a reason to sleep?
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.
I just copied the example verbatim from the original ticket, the wait is there: #4505