It is recurring, at least locally, when

It is recurring, at least locally, when creating a workflow. My code is very simple:
.post('/:integration/fetch', zValidator('param', z.object({ integration: z.string().min(1) })), async (ctx) => {
const { integration } = ctx.req.valid('param')
const instance = await ctx.env.HistoryIngestion.create({
id: integration,
params: { integrationId: integration },
})
await ctx.env.Jobs.put(
`workflow:${integration}`,
JSON.stringify({ instance: instance.id, status: 'pending', progress: 0, startedAt: Date.now() }),
)
return ctx.json({ success: true }, 202)
})
.post('/:integration/fetch', zValidator('param', z.object({ integration: z.string().min(1) })), async (ctx) => {
const { integration } = ctx.req.valid('param')
const instance = await ctx.env.HistoryIngestion.create({
id: integration,
params: { integrationId: integration },
})
await ctx.env.Jobs.put(
`workflow:${integration}`,
JSON.stringify({ instance: instance.id, status: 'pending', progress: 0, startedAt: Date.now() }),
)
return ctx.json({ success: true }, 202)
})
7 Replies
Caio
Caio3mo ago
Looking into it. Could you retry with:
.post('/:integration/fetch', zValidator('param', z.object({ integration: z.string().min(1) })), async (ctx) => {
const { integration } = ctx.req.valid('param')
using instance = await ctx.env.HistoryIngestion.create({
id: integration,
params: { integrationId: integration },
})
await ctx.env.Jobs.put(
`workflow:${integration}`,
JSON.stringify({ instance: instance.id, status: 'pending', progress: 0, startedAt: Date.now() }),
)
return ctx.json({ success: true }, 202)
})
.post('/:integration/fetch', zValidator('param', z.object({ integration: z.string().min(1) })), async (ctx) => {
const { integration } = ctx.req.valid('param')
using instance = await ctx.env.HistoryIngestion.create({
id: integration,
params: { integrationId: integration },
})
await ctx.env.Jobs.put(
`workflow:${integration}`,
JSON.stringify({ instance: instance.id, status: 'pending', progress: 0, startedAt: Date.now() }),
)
return ctx.json({ success: true }, 202)
})
using could solve this, is my guess
Gabriel Francisco
Gabriel FranciscoOP2mo ago
X [ERROR] 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. X [ERROR] An RPC result was not disposed properly. One of the RPC calls you made expects you to call dispose() on the return value, but you didn't do so. You cannot rely on the garbage collector for this because it may take arbitrarily long before actually collecting unreachable objects. same error :/ // @ts-ignore using instance = await this.workflow.create({ id: this.id, params }) @Caio how can I see which RPC result is causing the problem? is it possible to get a more detailed log?
Caio
Caio2mo ago
The only RPC call that I see on that code (against the Workflows control plane) is the .create one I'm trying to repro this. Can you give me a broad overview of what your workflow does? Is it long running, or does it finish fast?
Gabriel Francisco
Gabriel FranciscoOP2mo ago
long, ~3 hours
Caio
Caio2mo ago
Okay and can you confirm that this only happens on local dev? Or do you see this behavior on deployed workflows as well?
Gabriel Francisco
Gabriel FranciscoOP2mo ago
I can't find any logs of it on observability so I think its only local
bastian
bastian3w ago
I am seeing the same issue. Been trying to debug it for days... remove all my RPC calls but worklow.create is the only one left.

Did you find this page helpful?