punn
punn•2y ago

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?
No description
10 Replies
punn
punnOP•2y ago
This is the only log
No description
ballingt
ballingt•2y ago
Is React involved at any point in this process?
Presley
Presley•2y ago
How is the action invoked? Is it scheduled or invoked from React via useAction?
punn
punnOP•2y ago
not invoked by React. It's a runAction from a webhook.
punn
punnOP•2y ago
This is all invoked by the runAction in the third to last log POST /hostaway/webhook
No description
punn
punnOP•2y ago
FYI, this double message behaviour occurs intermittently. I would say for 1/5 messages.
presley
presley•2y ago
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?
ian
ian•2y ago
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.
punn
punnOP•2y ago
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 😅
presley
presley•2y ago
haha. I was very puzzled. We are very explicit in actions being at most once.

Did you find this page helpful?