Skip to content

Vitest False Positive in PR Added in-memory locks for the process, fix for Bug #2579 temporary measure. #3060 #3073

@davidw-philips

Description

@davidw-philips

Describe the bug

Vitest reports an “Unhandled Errors” warning for a test that intentionally throws an error ("should throw error for non-existent entity").
The test itself passes correctly using .rejects.toThrow(), but Vitest incorrectly surfaces the expected rejection as an unhandled error.

This causes the TypeScript / Test memory CI job to fail even though there is no bug in the memory server implementation.

To Reproduce

Steps to reproduce the behavior:

Run the memory server tests using:

pnpm test:memory

Look for the test:

"should throw error for non-existent entity"

Observe that the test passes but Vitest outputs an “Unhandled Errors” warning.

In GitHub Actions, this warning results in a failing test job.

Expected behavior

Vitest should correctly treat .rejects.toThrow() as a handled and expected error, and should not report the intentionally thrown error as an unhandled rejection.

CI should pass when the test succeeds, without false-positive warnings.

Logs

Example output:

Unhandled Errors:
❯ Error: Entity does not exist
at ...

The test reports PASS

The warning appears only in the "Unhandled Errors" summary

No runtime errors or implementation failures occur

Additional context

This behavior is a Vitest testing quirk, not a bug in the memory server code.

All locking, file serialization, and race condition tests pass successfully.

The new lock implementation is functioning as expected.

The false warning appears because Vitest sometimes logs expected async errors as “unhandled” even when wrapped in .rejects.toThrow().

Possible mitigations (optional):

Rewrite the test using assert.rejects(...)

Wrap error tests to avoid Vitest’s unhandled rejection reporting

Add scoped process.on("unhandledRejection", () => {}); for this file (not recommended except for CI cleanliness)

If you want, I can also rewrite the test file for a clean CI run.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions