Unhandled error with `vitest` and `Effect.withSpan`

Hi there!
I found a weird issue with vitest and Effect.withSpan. Here's a small test file.:
import { describe, it } from "vitest";
import { Effect } from "effect";

const withSpan = Effect.withSpan("bar", {
  attributes: {
    foo: "bar",
  },
})

describe("foo", () => {
  it.only("throws unhandled error", async () => {
    await Effect.fail(new Error("foo")).pipe(
      withSpan,
      Effect.runPromise
    );
  });
  it("fails with a normal error", async () => {
    await Effect.fail("foo").pipe(
      withSpan,
      Effect.runPromise
    );
  });
  it("fails with a normal error", async () => {
    await Effect.fail(new Error("foo")).pipe(Effect.runPromise);
  });
});

When I run the first test, I have an Unhandled error (see the first screenshost)
When I run only the second one (with withSpan but a string as the error) or when I only run the third one (no withSpan and an Error as the error) I don't have the issue. It fails as we would expect vitest to fail (see the second screenshot)
Any idea what's happening?
image.png
image.png
Was this page helpful?