can someone confirms AsyncLocalStorage

can someone confirms AsyncLocalStorage will not behave as expected in a step fn unless the callback is defined inline ?
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
await context.run({ id: "124" }, async () => {
// loadFile will get undefined when calling content.getStore()
const txt = await step.do("load", loadFile);
const txt2 = await step.do("load2",
// this one will work
async()=>console.log(context.getStore().id));
});
}
async run(event: WorkflowEvent<Params>, step: WorkflowStep) {
await context.run({ id: "124" }, async () => {
// loadFile will get undefined when calling content.getStore()
const txt = await step.do("load", loadFile);
const txt2 = await step.do("load2",
// this one will work
async()=>console.log(context.getStore().id));
});
}
3 Replies
Seekerdasbatatas
Seekerdasbatatas•4d ago
At the moment yes, ALS (AsyncLocalStorage) will not be propagated correctly to step inner functions. This is a limitation of JSRPC, but might be worked on in the future
advanced
advancedOP•4d ago
might be good to add that into the limits/caveats.
Seekerdasbatatas
Seekerdasbatatas•4d ago
will do, thanks for reporting 🙂

Did you find this page helpful?