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

🐛 BUG: Durable Object tests won't run, .sqlite error #5629

Open
punkeel opened this issue Apr 16, 2024 · 6 comments · May be fixed by #8173
Open

🐛 BUG: Durable Object tests won't run, .sqlite error #5629

punkeel opened this issue Apr 16, 2024 · 6 comments · May be fixed by #8173
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration

Comments

@punkeel
Copy link
Member

punkeel commented Apr 16, 2024

Which Cloudflare product(s) does this pertain to?

Workers Vitest Integration

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

0.1.19 [@cloudflare/vitest-pool-workers], 1.3.0 [vitest]

What version of Node are you using?

v20.7.0

What operating system and version are you using?

Mac Sonoma 14.4.1

Describe the Bug

Observed behavior

Tests fail with a fatal error when a fetch response body is not consumed by tests.

/Users/maxime/.nvm/versions/node/v20.7.0/bin/node /Users/maxime/Code/NC/lalala/node_modules/vitest/vitest.mjs --run --reporter ../../../Applications/WebStorm.app/Contents/plugins/javascript-impl/helpers/vitest-intellij/node_modules/vitest-intellij-reporter-safe.js --testNamePattern=^ ?smoke checks 404s on non-consume path$ /Users/maxime/Code/NC/lalala/src/durable_objects/Lalala.test.ts
▲ [WARNING] Processing wrangler.toml configuration:

    - "unsafe" fields are experimental and may change or break at any time.


[vpw:inf] Starting single runtime for vitest.config.js...

================================================================================
Failed to pop isolated storage stack frame in src/durable_objects/Lalala.test.ts's test "404s on non-consume path".
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/47/5fsq322s5dx9y0f1c2shbvvh0000gn/T/miniflare-0d475a4a00fc573e720de1f3fdc5d38f/do/vitest-pool-workers-runner--__VITEST_POOL_WORKERS_USER_OBJECTLalala/88e8e9cf16735464763622e7564089aa29822a772684bb26d1a72a7edc321ec8.sqlite-shm
================================================================================

Error running worker: AssertionError [ERR_ASSERTION]: Isolated storage failed. There should be additional logs above.
    at new AssertionError (node-internal:internal_assertionerror:419:15)
    at Function.strictEqual (node-internal:internal_assert:200:11)
    at WorkersTestRunner.updateStackedStorage (Users/maxime/Code/NC/lalala/node_modules/@cloudflare/vitest-pool-workers/dist/worker/lib/cloudflare/test-runner.mjs:107:12)
    at WorkersTestRunner.onAfterRunSuite (Users/maxime/Code/NC/lalala/node_modules/@cloudflare/vitest-pool-workers/dist/worker/lib/cloudflare/test-runner.mjs:142:5)
    at runSuite (Users/maxime/Code/NC/lalala/node_modules/@vitest/runner/dist/index.js:875:5)
    at runFiles (Users/maxime/Code/NC/lalala/node_modules/@vitest/runner/dist/index.js:896:5)
    at startTests (Users/maxime/Code/NC/lalala/node_modules/@vitest/runner/dist/index.js:905:3)
    at Users/maxime/Code/NC/lalala/node_modules/vitest/dist/chunks/runtime-runBaseTests.0UwIvo_U.js:114:7
    at withEnv (Users/maxime/Code/NC/lalala/node_modules/vitest/dist/chunks/runtime-runBaseTests.0UwIvo_U.js:82:5)
    at run (Users/maxime/Code/NC/lalala/node_modules/vitest/dist/chunks/runtime-runBaseTests.0UwIvo_U.js:103:3)

Failure cause not provided for '404s on non-consume path'

Isolated storage failed. There should be additional logs above.
AssertionError [ERR_ASSERTION]: Isolated storage failed. There should be additional logs above.
    at new AssertionError (node-internal:internal_assertionerror:419:15)
    at Function.strictEqual (node-internal:internal_assert:200:11)
    at WorkersTestRunner.updateStackedStorage (Users/maxime/Code/NC/lalala/node_modules/@cloudflare/vitest-pool-workers/dist/worker/lib/cloudflare/test-runner.mjs:107:12)
    at WorkersTestRunner.onAfterRunSuite (Users/maxime/Code/NC/lalala/node_modules/@cloudflare/vitest-pool-workers/dist/worker/lib/cloudflare/test-runner.mjs:142:5)
    at runSuite (Users/maxime/Code/NC/lalala/node_modules/@vitest/runner/dist/index.js:875:5)
    at runFiles (Users/maxime/Code/NC/lalala/node_modules/@vitest/runner/dist/index.js:896:5)
    at startTests (Users/maxime/Code/NC/lalala/node_modules/@vitest/runner/dist/index.js:905:3)
    at Users/maxime/Code/NC/lalala/node_modules/vitest/dist/chunks/runtime-runBaseTests.0UwIvo_U.js:114:7
    at withEnv (Users/maxime/Code/NC/lalala/node_modules/vitest/dist/chunks/runtime-runBaseTests.0UwIvo_U.js:82:5)
    at run (Users/maxime/Code/NC/lalala/node_modules/vitest/dist/chunks/runtime-runBaseTests.0UwIvo_U.js:103:3)

That error is very confusing.

Please provide a link to a minimal reproduction

https://github.com/punkeel/repro-5629

Run make to run tests.

@punkeel punkeel added the bug Something that isn't working label Apr 16, 2024
@github-project-automation github-project-automation bot moved this to Untriaged in workers-sdk Apr 16, 2024
@hansottowirtz
Copy link

We're having the same issue, commenting out assert.strictEqual(res.status, 204, await res.text()); inside of /node_modules/@cloudflare/vitest-pool-workers/dist/worker/lib/cloudflare/test-runner.mjs:107 works as a temporary solution.

@shonubijerry
Copy link

I ran into this issue, so sad I spent time digging. Is there any updates on the PR that was raised to fix it?

@hansottowirtz
Copy link

Hi @shonubijerry, I'm not sure how to fix this one as I don't know enough about SQLite. I've patched the node module for now (using yarn patch)

@penalosa penalosa added the vitest Relating to the Workers Vitest integration label Jul 22, 2024
@feliperohdee
Copy link

hi, I'm going to share my experience which worked for me. According to docs (https://developers.cloudflare.com/workers/runtime-apis/rpc/lifecycle/#explicit-resource-management) you must dispose stubs after have used them, doing:

stub response have a dispose interface on them, which must be called as stubInstance[Symbol.dispose]()

const stub = env.DURABLE_BJECT.get(...);

try {
    // you test condition here
} finally {
    stub[Symbol.dispose]!();
}

or just use:

import { runInDurableObject } from 'cloudflare:test';

described here https://developers.cloudflare.com/workers/testing/vitest-integration/test-apis/#durable-objects

@andyjessop
Copy link
Contributor

Thanks everyone, and thanks @feliperohdee for the links. It looks like it's worth at the very least making this error message more helpful. I'll add it to our work backlog.

@andyjessop andyjessop moved this from Untriaged to Backlog in workers-sdk Aug 7, 2024
@yarolegovich
Copy link

Was getting the same error and the natural thing to try was disposing my DO like @feliperohdee.
This didn't help, but the error was gone when I tried to [Symbol.dispose]() the RPC result, even though it's a plain { string, string } struct which I expect should be just cloned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working vitest Relating to the Workers Vitest integration
Projects
Status: Backlog
7 participants