An RPC stub was not disposed properly using meta frameworks
I wanted to open a thread here regarding this issue. I have seen multiple people inlucuding myself that gets this error.
I absolutely understand where this error is comming from, finding the solution here is the issue.
Small explanation: If you use a meta framework like sveltekit etc and you use RPC on the server (service binding from a normal worker) you will run into this issue. Sadly
using
or [Symbol.dispose]()
dosent seem to work in those enviroments. You will run into framework errors like TypeError: products[Symbol.dispose] is not a function
(and if you check if Symbol.dispose exists before trying to dispose it never exists and you still get the error)
So i was wondering if there is a solution? If this is a known issue that is being worked on?
There was a small discussion here but without any solution sadly https://discord.com/channels/595317990191398933/773219443911819284/1360010131462557879
Would be nice to know if RPC isnt recommended to use in meta frameworks due to this issue17 Replies
I had encountered this as well and was able to fix it through use of a helper function on the consumer side (i.e., when I make the RPC request).
Your mileage may vary but hopefully this works for you.
thanks i will check it out!
yep sadly as expected. i still get the error. Symbol.dispose seems to never exist. at least in sveltekit
What's your RPC method look like?
How are you implementing it?
well curretly i have the silly setup where my do has a rpcTarget and my worker returns that so i can basically use DO RPCs in local dev
but yea i also ran into the issue with a more normal setup
but its weird i made a minimal reproduction repo with that setup and i just dont get the error in there
You're using a WorkerEntrypoint? The methods are async?
yes im using WorkerEntrypoint. i played around with them being async and not but it dosent seem to make any difference but i might be wrong here
it looks something like this
index.ts
do.ts
with this minimal setup i dont ever get the stub error weirdly
Service Worker
Consumer Worker
This would be a minimal example worker-to-service worker.but in a worker to worker context couldnt you just use
using
?Not unless I use the experimental worker.
AFAIK
no afaik wrangler 4 is polyfilling or w/e automatically
I hadn't seen that update.
I also have limited DO experience so, my examples might not be 1:1.

That's awesome. I hated wrapping method calls to bypass the issue.
i see. well with meta frameworks
using
breaks everything thats why i am not using it
oh well i will keep digging because even if the error is rare and random, it dosent make sense that it never pops up in my minimal code baseI noticed it was inconsistent as well.
Usually when I was making a buttload of RPC calls in a short period of time.
yea must be something like that
but even then its super weird. i think for me it happens the most often when i do an rpc call and refresh my page but even then happens like 1 out of 15 times