Skip to content

An RPC stub was not disposed properly using Meta-fameworks (SvelteKit) #9537

Closed as not planned
@Sillyvan

Description

@Sillyvan

What versions & operating system are you using?

Wrangler 4.19.1, Node v22, MacOS

Please provide a link to a minimal reproduction

https://github.com/sillyvan/workers-effect

Describe the Bug

Some initial info:

  • First this has nothing to do with Effect which is used in the Repo
  • From what i have seen on Discord, its not only SvelteKit but other vite based meta-frameworks like Remix/RR
  • The code seems to work regardless
  • Only tested on local. not in prod

An RPC stub was not disposed properly. You must call dispose() on all stubs in order to let the other side know that you are no longer using them. You cannot rely on the garbage collector for this because it may take arbitrarily long before actually collecting unreachable objects. As a shortcut, calling dispose() on the result of an RPC call disposes all stubs within it.

Because using dosen't seem to work with default vite settings, i tried using:

const products = await platform!.env.WORKER.getProducts();
products[Symbol.dispose]?.();

where products is type of:

let products: ({
    id: number;
...
}[] & Disposable) | undefined

but products[Symbol.dispose] always seems undefined.

I have seen this issue multiple times on discord but i never saw any solution nor answer for this.

Please provide any relevant error logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that isn't working

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions