{"action":"created","issue":{"url":"https://api.github.com/repos/functional-streams-for-scala/fs2/issues/1305","repository_url":"https://api.github.com/repos/functional-streams-for-scala/fs2","labels_url":"https://api.github.com/repos/functional-streams-for-scala/fs2/issues/1305/labels{/name}","comments_url":"https://api.github.com/repos/functional-streams-for-scala/fs2/issues/1305/comments","events_url":"https://api.github.com/repos/functional-streams-for-scala/fs2/issues/1305/events","html_url":"https://github.com/functional-streams-for-scala/fs2/issues/1305","id":376912103,"node_id":"MDU6SXNzdWUzNzY5MTIxMDM=","number":1305,"title":"Inconsistent CompositeFailures","user":{"login":"mpilquist","id":118078,"node_id":"MDQ6VXNlcjExODA3OA==","avatar_url":"https://avatars2.githubusercontent.com/u/118078?v=4","gravatar_id":"","url":"https://api.github.com/users/mpilquist","html_url":"https://github.com/mpilquist","followers_url":"https://api.github.com/users/mpilquist/followers","following_url":"https://api.github.com/users/mpilquist/following{/other_user}","gists_url":"https://api.github.com/users/mpilquist/gists{/gist_id}","starred_url":"https://api.github.com/users/mpilquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpilquist/subscriptions","organizations_url":"https://api.github.com/users/mpilquist/orgs","repos_url":"https://api.github.com/users/mpilquist/repos","events_url":"https://api.github.com/users/mpilquist/events{/privacy}","received_events_url":"https://api.github.com/users/mpilquist/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-02T18:00:20Z","updated_at":"2018-11-02T18:11:10Z","closed_at":"2018-11-02T18:11:09Z","author_association":"MEMBER","body":"```scala\r\n@ val s = Stream.bracket(IO.unit)(_ => IO.raiseError(new RuntimeException(\"Finalizer failed\"))).flatMap(_ => Stream.raiseError[IO](new RuntimeException(\"Inner failed\")))\r\ns: Stream[IO[x], Nothing] = Stream(..)\r\n\r\n@ s.attempt.compile.lastOrError.unsafeRunSync\r\nres2: Either[Throwable, Nothing] = Left(fs2.CompositeFailure: Multiple exceptions were thrown (2), first java.lang.RuntimeException: Inner failed)\r\n\r\n@ s.compile.lastOrError.attempt.unsafeRunSync\r\nres3: Either[Throwable, Nothing] = Left(java.lang.RuntimeException: Inner failed)\r\n```\r\n\r\nI'd expect to get a `CompositeFailure` in both of these cases. The second case looks wrong to me. @pchlupacek @AdamChlupacek "},"comment":{"url":"https://api.github.com/repos/functional-streams-for-scala/fs2/issues/comments/435464130","html_url":"https://github.com/functional-streams-for-scala/fs2/issues/1305#issuecomment-435464130","issue_url":"https://api.github.com/repos/functional-streams-for-scala/fs2/issues/1305","id":435464130,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNTQ2NDEzMA==","user":{"login":"mpilquist","id":118078,"node_id":"MDQ6VXNlcjExODA3OA==","avatar_url":"https://avatars2.githubusercontent.com/u/118078?v=4","gravatar_id":"","url":"https://api.github.com/users/mpilquist","html_url":"https://github.com/mpilquist","followers_url":"https://api.github.com/users/mpilquist/followers","following_url":"https://api.github.com/users/mpilquist/following{/other_user}","gists_url":"https://api.github.com/users/mpilquist/gists{/gist_id}","starred_url":"https://api.github.com/users/mpilquist/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpilquist/subscriptions","organizations_url":"https://api.github.com/users/mpilquist/orgs","repos_url":"https://api.github.com/users/mpilquist/repos","events_url":"https://api.github.com/users/mpilquist/events{/privacy}","received_events_url":"https://api.github.com/users/mpilquist/received_events","type":"User","site_admin":false},"created_at":"2018-11-02T18:11:09Z","updated_at":"2018-11-02T18:11:09Z","author_association":"MEMBER","body":"Ah I have a vague notion of what's happening. In the first case, we force the exception to get handled by the FS2 stream interpreter. In the second case, the finalizer is executed from the finalizer of the overall effect, which closes the root scope. When that exception is thrown, the `Bracket[IO]` instance suppresses the finalizer exception.\r\n\r\nIndeed, this is visible in `res3`:\r\n\r\n```scala\r\n@ res3.getSuppressed\r\nres4: Array[Throwable] = Array(java.lang.RuntimeException: Finalizer failed)\r\n```\r\n\r\nClosing this as working as expected."}}
{"actor":{"display_login":"mpilquist"}}