Lambda调用回调后超时 [英] Lambda Timing out after calling callback

查看:72
本文介绍了Lambda调用回调后超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Javascript 4.3运行时中使用了两个lambda函数.我运行第一个,它同步调用第二个(同步是意图).问题是第二次超时(60秒),但实际上仅22秒后就成功完成了一次.

I'm using two lambda functions with Javascript's 4.3 runtime. I run the first and it calls the second synchronously (sync is the intent). Problem is the second one times out (at 60sec) but it actually reaches a successful finish after only 22 seconds.

以下是两个Lambda函数之间的流程:

Here's the flow between the two Lambda functions:

Lamda函数 A 我不再需要CloudWatch日志,但真正的问题(我认为)是函数 B ,该函数无缘无故地超时.

Lamda function A I am no longer getting CloudWatch logs for but the real problem (I think) is function B which times out for no reason.

以下是一些CloudWatch日志来说明这一点:

Here's some CloudWatch logs to illustrate this:

函数B末尾的代码-包括上图所示的成功"日志语句-包括在下面:

The code in Function B at the end -- which includes the "Success" log statement see in picture above -- is included below:

最初,我只有callback(null, 'successful ...')行,而没有上下文调用succeed()的nodejs 0.10.x方式.无奈之下,我将两者都添加了,但结果却是相同的.

Originally I only had the callback(null, 'successful ...') line and not the nodejs 0.10.x way where you called succeed() off of context. In desperation I added both but the result is the same.

任何人都知道发生了什么事吗?有什么可以调试的方式吗?

Anyone have an idea what's going on? Any way in which I can debug this?

如果A和B之间的调用逻辑使B的启动状态有所不同,则为以下调用:

In case the invocation logic between A and B makes a difference in the state that B starts in, here's the invocation:

推荐答案

Michael-sqlbot 所述;问题似乎是,只要存在打开的连接,由于非空事件循环,调用回调不会终止该函数.打开Redis连接时遇到了同样的问题;所述的解决方案是context.callbackWaitsForEmptyEventLoop = false;

As Michael - sqlbot said; the issue seems to be that as long as there is an open connection, because of the non empty event loop, calling the callback doesn't terminate the function. Had the same problem with a open Redis connection; solution as stated is context.callbackWaitsForEmptyEventLoop = false;

这篇关于Lambda调用回调后超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆