Unusual Response Time Issue while Handling Webhooks

Options

Hi,

I recently encountered an unusual error. Whenever a user sends me a WhatsApp message, I receive a webhook from WhatsApp Cloud API, and I need to respond with a 200 status immediately. I have been able to do so within 2 seconds consistently.

However, something unusual happened today that I am unable to understand. If you refer to the attached image, you'll notice that the function stack only took 2.4 seconds to execute. However, the total duration displayed in the timer is 60 seconds. It actually took 60 seconds to respond to the webhook. As a result, WhatsApp made another attempt to send me the same webhook immediately. This time it took 34 seconds to send a response, which is also long according to WhatsApp guidelines. So I received the same webhook again for the third time, and it executed in about 7 seconds.

Consequently, my workflows ahead were triggered three times, and the user received a response from my application three times.

Please note that I am currently testing my application, and my team member was the user. I do not have any external users on the app, so the workload on my app is negligible. I am currently on the Launch Plan.

Secondly, in another function stack of mine, during Run & Debug, I encountered a memory issue a couple of times while running a query for all records which had to only fetch 10 records. The error read as "Unknown Error - This may be a random occurrence or a memory issue"

My concerns are as follows:

  1. Why did it take so long to send a response to the webhook when my function stack only took about 2 seconds?
  2. How can I ensure that a similar issue does not occur again?

I plan to launch my application soon, and such errors would create a bad experience for my users. Kindly guide.

Thank you.

Answers