Nope, we are in the CF purgatory when it comes to vitest + workflows. :NotLikeThis:
Nope, we are in the CF purgatory when it comes to vitest + workflows. :NotLikeThis:
waitUntil code? waitUntil, because it garbage collects the state and tears down the execution environment after the Workflow instance is registered but BEFORE the workflow is actually run. The sleep prevents the premature shutdown of the Worker execution context. run method without wrapping it inside a step.do. My examples are zod validation of params or something like const ai = new GoogleGenAI().. I theory I don't want to persist those, I'm fine if they run again on a new try. So would it be best to put them in the global run scope?
waitUntilwaitUntilstep.dozodconst ai = new GoogleGenAI()entryErrorContext = jsgInternalError; wdErrId = cbiok85ihdsus98r7iao99nq
workerd/jsg/util.c++:320: error: e = workerd/util/sqlite.c++:499: failed: expected _ec ==
SQLITE_OK [7 == 0]; out of memory: SQLITE_NOMEM
stack:
./node_modules/@cloudflare/workerd-linux-64/bin/workerd@2667f9d
./node_modules/@cloudflare/workerd-linux-64/bin/workerd@2667c9d
./node_modules/@cloudflare/workerd-linux-64/bin/workerd@1af50ab
./node_modules/@cloudflare/workerd-linux-64/bin/workerd@1af4cee
./node_modules/@cloudflare/workerd-linux-64/bin/workerd@1af49b8// Worker
ctx.waitUntil(
nonBlockingFunc({ ... })
);
async nonBlockingFunc() {
const workflowInstance = await env.MY_WORKFLOW.create();
// await new Promise((resolve) => setTimeout(resolve, 2000)); // sleep fixes???
return workflowInstance.id;
} .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)
})