Skip to content

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

Description

@parrotmac

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 (vitest-dev/vitest#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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingreleased

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions