Replies: 1 comment 1 reply
-
Wow, this took a long time to figure out. Basically, if you read the documentation carefully, you will find that you are supposed to wrap all code that is non-pure using Do not do this: export const suggestArticleSources = inngest.createFunction(
{
id: 'suggestArticleSources',
retries: 0,
},
{ event: 'aimd/suggest-article-sources.start' },
async ({ event, step, runId, logger }) => {
const ids = [Math.random(), Math.random(), Math.random()];
await doSomethingWithIds(ids);
}
); Instead, do this: export const suggestArticleSources = inngest.createFunction(
{
id: 'suggestArticleSources',
retries: 0,
},
{ event: 'aimd/suggest-article-sources.start' },
async ({ event, step, runId, logger }) => {
const ids = await step.run('get-ids', () => {
return [Math.random(), Math.random(), Math.random()];;
})
await step.run('run-something', () => {
return doSomethingWithIds(ids);
});
}
); Makes sense, but really wish this was illustrated better in the documentation. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been debugging this for many hours.
I send an event like this:
This is the only place the event is ever sent.
Then I log when my function is invocation:
Here is a meta code:
Notice how:
What is happening?
WOAH, very confusing. I stripped the code to just:
and seeing this...
Why does it keep invoking itself?
But I don't see anything weird in the UI. So why is the same function getting called repeatedly?
Beta Was this translation helpful? Give feedback.
All reactions