简体   繁体   English

您如何处理短暂的 webhook 超时? (节点.js)

[英]How do you handle a short webhook timeout? (Node.js)

I have set up the eSignatures API for our app and until recently it has been working perfectly.我已经为我们的应用程序设置了 eSignatures API,直到最近它一直运行良好。 The part that is now broken is the webhook function.现在被破坏的部分是 webhook 功能。 So when a document gets signed by one of our clients, it triggers our webhook cloud function that then updates our database (seems simple?).因此,当我们的一位客户签署文档时,它会触发我们的 webhook 云功能,然后更新我们的数据库(看起来很简单?)。

The problem is that eSignatures have now updated their timeout to only 8 seconds, which means that my function does not have enough time to run and respond to their servers.问题是电子签名现在已将其超时更新为仅 8 秒,这意味着我的函数没有足够的时间来运行和响应其服务器。 It does however still run and update the database correctly, but as it takes longer than 8 seconds, the 200 response never reaches eSignatures and therefore they retry the endpoint every hour (for ~5/6 hours).然而,它仍然正确地运行和更新数据库,但由于它花费的时间超过 8 秒,因此 200 响应永远不会到达电子签名,因此它们每小时(约 5/6 小时)重试端点。 I have put in a catch so that data is not duplicated when this happens, but ideally we don't want the retries to take place!我已经设置了一个问题,以便在发生这种情况时不会重复数据,但理想情况下我们不希望重试发生!

My question is basically, is there a way to send a 200 response at the beginning of the function to eSginatures, and then continue with the updates?我的问题基本上是,有没有办法在函数开始时向 eSginatures 发送 200 响应,然后继续更新? Or is there another solution to handle this timeout?或者是否有其他解决方案来处理此超时? As if anything does fail in the function, I still want to return a 4xx to eSignatures and in this case we will want the retry?好像函数中的任何内容都失败了,我仍然想向 eSignatures 返回 4xx,在这种情况下,我们需要重试吗?

You can't send a response from your Cloud Functions and then continue executing tasks.您无法从 Cloud Functions 发送响应,然后继续执行任务。 When the response is sent, the Function is stopped.当响应被发送时,函数停止。 See this link and this one看到这个链接这个

But even if you could, sending a response before ending the tasks that your Cloud Function prevents you from sending a 4XX response if they fail.但即使可以,在结束任务之前发送响应,如果它们失败,您的云功能会阻止您发送 4XX 响应。 Hence, eSginatures would never retry.因此,eSginatures 永远不会重试。

I don't think you can do much else aside from possibly optimizing your Cloud Function or increasing the eSignatures timeout, which I don't think is possible ATM.我认为除了可能优化您的云功能或增加电子签名超时之外,您无能为力,我认为这在 ATM 上是不可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM