Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vitest not working with uwebsockets.js #5576

Closed
6 tasks done
chanon opened this issue Apr 21, 2024 · 3 comments
Closed
6 tasks done

Vitest not working with uwebsockets.js #5576

chanon opened this issue Apr 21, 2024 · 3 comments

Comments

@chanon
Copy link

chanon commented Apr 21, 2024

Describe the bug

Just calling uwebsocket's App() will terminate the test and Vitest will not show results of any tests.

I have tried looking through the Vitest documentation to see what the problem could be, but did not find anything.

Reproduction

Complete minimal reproduction in github repo:
https://github.com/chanon/vitest-uws/

The test code in tests/minimal.test.ts:

import { test } from "vitest"
import { App } from 'uWebSockets.js'

test("test it", async () => {
	try {
		console.log('before App()')
		// try commenting out the App() call
		App()
		console.log('after App()')
	}
	catch (e) {
		console.log(e)
	}
})

Run

pnpm install
pnpm vitest

Result:

image

Comment App() call and run again.

Result:

image

System Info

(Relevant info:)

 System:
    OS: Windows 10 
  Binaries:
    Node: 20.9.0
    pnpm: 9.0.4

Used Package Manager

pnpm

Validations

@AriPerkkio
Copy link
Member

Tested this on Github Codespaces and it works fine there. Does vitest --pool=forks make this work better on Windows?

@chanon
Copy link
Author

chanon commented Apr 21, 2024

Aha! yes. That works. I somehow missed that in the docs.

@chanon chanon closed this as completed Apr 21, 2024
@AriPerkkio
Copy link
Member

The uWebSockets.js seems to be native node addon. Those have some compatibility issues with Vitest's default pool. In the next major we'll be defaulting to pool: 'forks' so that this kind of issues would not come up: #5047

@github-actions github-actions bot locked and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants