Actions execute twice
I've been noticing that a fetch() call from an action seems to run twice.
For context, I'm sending a message using an external API. I have a helper function that calls fetch(). An action runs that helper function.
In logs, I see only the action running once. However, the message is sent twice and it has different content on each send. Since I'm generating the reply by calling gpt3.5, it seems like the whole action ran again even if the logs don't show it.
Any ideas?
10 Replies
This is the only log
Is React involved at any point in this process?
How is the action invoked? Is it scheduled or invoked from React via useAction?
not invoked by React. It's a runAction from a webhook.
This is all invoked by the runAction in the third to last log
POST /hostaway/webhook
FYI, this double message behaviour occurs intermittently. I would say for 1/5 messages.
Huh. That is very strange given we explicitly don't retry actions anywhere. Just to confirm, I got all the symptoms correct. You are calling an action from a webhook. You are positive the webhook is only called once. The logs are all correct in that everything is only logged once, but somehow the actions seem to run insert the message twice? And it seems like the whole actions is run twice?
Is that a Node.js action or it runs in Convex javascript environment?
It looks like the webhook is taking just over 10s. Is it possible the service calling the webhook gives up after 10s and retries it?
One thing you might notice is funny ordering - the logs from an action may be posted after the logs from the mutations / queries it runs.
it is a nodejs action. And the symptoms are as described. This morning is was working, inserting only single messages for a long chain of messages. So I will reobserve the issue again and update if it persists.
The webhook seems to be called once, and i Cmd+F'ed the openai call which only appeared once in the logs
Let me get back to this tonight after some more thorough testing
Resolved.
Webhook was misconfigured and fired to both prod and dev instances. False alarm 😅
haha. I was very puzzled. We are very explicit in actions being at most once.