Skip to content

🐛 BUG: Vitest Integration failure with error thrown from Durable Object RPC #7707

@its-jman

Description

@its-jman

Which Cloudflare product(s) does this pertain to?

Wrangler, Workers Vitest Integration

What versions are you using?

3.100.0 [Wrangler], 20.11.1 [Node]

What operating system and version are you using?

Mac 15.1.1

Please provide a link to a minimal reproduction

https://github.com/its-jman/rpc-error-repro

Describe the Bug

With a durable object, and vitest integration as simple as:

export class MyDurable extends DurableObject {
  async myCustomFunc() { throw new Error("My impl is broken") }
}

And running tests through the vitest integration:

it('fetches feed', async () => {
  const stub = env.MY_DURABLE.get(env.MY_DURABLE.idFromName('main'))
  const res = await expect(() => stub.myCustomFunc()).rejects.toThrowError()
})

I end up with Vitest caught 1 unhandled error during the test run., and Failed to pop isolated storage stack frame

I'd expect this to be propagated up through rpc as it is mentioned in the docs here so Vitest can handle it.

Why doesn't this error propagate to get handled by Vitest? What is the suggested way to handle thrown errors in implementation in tests?

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