effect icon indicating copy to clipboard operation
effect copied to clipboard

From Discord: Unhandled error with `vitest` and `Effect.withSpan`

Open effect-bot opened this issue 1 year ago • 0 comments

Summary

Summary

Several users are experiencing an issue with vitest and Effect.withSpan from the effect library. Specifically, when running a test that involves Effect.withSpan and an Error object, an unhandled error occurs. This issue does not appear when the error is a string or when Effect.withSpan is not used.

Key Takeaways

  1. Issue Description:

    • When running a test with Effect.withSpan and an Error object, an unhandled error occurs.
    • The issue does not occur when the error is a string or when Effect.withSpan is not used.
  2. Workaround:

    • Catching the error using .catch(e => { console.log(e) }) prevents the unhandled error.
  3. Version Specific:

    • The issue does not occur in vitest version 1.5.3 but is present in version 1.6.0.
  4. Potential Cause:

    • The problem seems to be related to the handling of file:// URLs in stack traces. Specifically, the absence of file:// in certain parts of the stack trace causes the issue.
  5. Code Insight:

    • The line this[FiberFailureCauseId] = cause in FiberFailureImpl might be causing the issue.
    • Removing this line or modifying it to include cause: this[FiberFailureCauseId].toJSON() can serve as a temporary fix.

Conclusion

The issue appears to be related to how vitest handles stack traces and file:// URLs in its newer version (1.6.0). Users experiencing this issue can either downgrade to version 1.5.3 or apply the suggested code modifications as a temporary workaround.

Discord thread

https://discord.com/channels/795981131316985866/1242486270547067012

effect-bot avatar May 24 '24 13:05 effect-bot