Workers RPC — Lifecycle · Cloudflare Wor...

Hi all! I'm running into the following error when using Workflows:
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.


I see that
step.do
expects to return
Rpc.Serializable<unknown>
, so I did a little bit of reading about the RPC lifecycle here and found that in the context of Worker Service Bindings, you should either use the experimental
using
syntax, or explicitly call
object[Symbol.dispose]()
.

I'm a little confused because this error is only thrown after some calls to
step.do
, and not others. If someone could provide some insight as to what's going on, that would be great. Happy to provide more details also
Cloudflare Docs
Memory management, resource management, and the lifecycle of RPC stubs.
Workers RPC — Lifecycle · Cloudflare Workers docs
Was this page helpful?