The examples you provided in https://

The examples you provided in https://github.com/cloudflare/workers-sdk/tree/main/fixtures/vitest-pool-workers-examples are really useful! I was in particular looking for a best practice example to test WebSockets. I was trying the following setup (which is roughly how it worked in Miniflare v2):
const res = await SELF.fetch('http://example.com/socket')
expect(res.status).toBe(101)
const ws = res.webSocket
const res = await SELF.fetch('http://example.com/socket')
expect(res.status).toBe(101)
const ws = res.webSocket
But when running those tests, I'm now getting the following error:
================================================================================
Failed to pop isolated storage stack frame in test/my-test.test.ts's test "my test name".
This usually means your Worker tried to access storage outside of a test.
In particular, we were unable to pop Durable Objects storage.
Ensure you `await` all `Promise`s that read or write to these services.

- AssertionError [ERR_ASSERTION]: Expected .sqlite, got /var/folders/ph/xtwbrg097hsby7l_v3yzqksh0000gn/T/miniflare-d4b6f5b59731af8a4d2079c3f7c923b6/do/vitest-pool-workers-runner--__VITEST_POOL_WORKERS_USER_OBJECTLiveRoom/36eb1b7b24b6678dfb0707d527ae23bbe288829018c83c94adcc7346b887f05b.sqlite-shm
================================================================================
================================================================================
Failed to pop isolated storage stack frame in test/my-test.test.ts's test "my test name".
This usually means your Worker tried to access storage outside of a test.
In particular, we were unable to pop Durable Objects storage.
Ensure you `await` all `Promise`s that read or write to these services.

- AssertionError [ERR_ASSERTION]: Expected .sqlite, got /var/folders/ph/xtwbrg097hsby7l_v3yzqksh0000gn/T/miniflare-d4b6f5b59731af8a4d2079c3f7c923b6/do/vitest-pool-workers-runner--__VITEST_POOL_WORKERS_USER_OBJECTLiveRoom/36eb1b7b24b6678dfb0707d527ae23bbe288829018c83c94adcc7346b887f05b.sqlite-shm
================================================================================
I've also tried closing the socket at the end of the test to see if it maybe the be cause of the error, but as soon as I call ws.close() , it even segfaults (see https://gist.github.com/nvie/85a9f9c33efe81db4b95c3288f507c3f#file-error-log-L3). Would you be able to provide an example test to test a WebSocket connection in an integration test in the new Vitest + Miniflare v3 setup? 🙏
2 Replies
MrBBot
MrBBot8mo ago
Hey! 👋 I'll try put an example together, but that segfault is interesting. Would you be able to put together a minimal reproduction?
Vincent
VincentOP8mo ago
I can try doing that somewhere next week, as I suspect it's going to take me a bit of time to make this a minimal reproduction, as we're dealing with a quite complicated existing setup right now. Will get back to you later!
Want results from more Discord servers?
Add your server