sidequest icon indicating copy to clipboard operation
sidequest copied to clipboard

Worker calls to `process.send(...)` break Vitest tests when using `--pool=forks`

Open parrotmac opened this issue 5 months ago • 2 comments

Hey there!

I'm running into an issue when using this library in a codebase that uses Vitest for testing while using pool: 'forks'. In turn, I'm using forks to avoid issues with Prisma (https://github.com/vitest-dev/vitest/issues/3106)

If the Sidequest engine is [transitively] imported into a test, the process.send call (specifically, process.send("ready")) causes Vitest to throw an error.

I think there are at least a couple ways around this

  • Use a sentinel environment variable that causes the worker task to only send events when this is set. However, this would probably expose that environment variable to sub-tasks, which is an API surface decision to be made.
  • Separate the worker initialization so it's not called by default (e.g. when writing import { Sidequest } from "sidequest")

For the immediate future I'm going to mock sidequest in my test environment since the tests aren't targeted at Sidequest machinery.

A minimal reproduction of the issue is available here, showcasing both a raw process.send(...) and using sidequest itself.

Thanks!

parrotmac avatar Jun 11 '26 19:06 parrotmac

Hey @parrotmac. Thanks for your input.

Yes, we also had some issues with Vitest. We used thread pools for vitest, but I understand this is not an option for you.

What is a bit strange is that simply importing Sidequest breaks your tests, even without starting it.

I will look into it when I have the chance!

GiovaniGuizzo avatar Jun 11 '26 19:06 GiovaniGuizzo

:tada: This issue has been resolved in version 1.15.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

sidequest-release[bot] avatar Jun 18 '26 18:06 sidequest-release[bot]