Skip to content

🐛 BUG: vitest-pool-workers: You need to consume the R2 body or tests fail #5524

@WalshyDev

Description

@WalshyDev

Which Cloudflare product(s) does this pertain to?

Workers Vitest Integration

What version(s) of the tool(s) are you using?

@cloudflare/vitest-pool-workers: 0.1.16, vitest: 1.3.0

What version of Node are you using?

v20.6.1

What operating system and version are you using?

Mac Sonoma 14.2

Describe the Bug

Observed behavior

Test fails with:

Failed to pop isolated storage stack frame in tests/r2.test.ts's test "Can repro".
This usually means your Worker tried to access storage outside of a test.
In particular, we were unable to pop R2 storage.
Ensure you await all Promises that read or write to these services.

Error running worker: AssertionError [ERR_ASSERTION]: Isolated storage failed. There should be additional logs above.

Expected behavior

This should either just work or at least give an error message telling me to consume/cancel the body. It's quite hard to know why it's failing atm so while in the middle of writing a test, if you haven't written code to consume the body yet (maybe you just don't need to) it's very hard to see the issue.

Steps to reproduce

Repro available here: https://github.com/Walshy-testing/vitest-r2-repro

test('Can repro', async () => {
	const file = await env.R2.put('abc', 'def');
	expect(file).not.toBe(null);
	expect(file?.etag).toBe('4ed9407630eb1000c0f6b63842defa7d');

	// Check the file exists
	const read = await env.R2.get('abc');
	expect(read).not.toBe(null);
});

Please provide a link to a minimal reproduction

https://github.com/Walshy-testing/vitest-r2-repro

Please provide any relevant error logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that isn't workingvitestRelating to the Workers Vitest integration

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions