All my handler working fine after one request handler timeout then all next request timeout too.
This is my log.
๏
09:03:33
START RequestId: 91f3b0c1-1dcc-11e7-b0f1-85e057390cac Version: $LATEST
๏
09:03:33
info: {"version":"1.0","session":{"new":true,"sessionId":"SessionId.b2d4fee6-c0f8-4c87-837b-0d4af004b7ae","application":{"applicationId":"amzn1.ask.skill.00a11412-2750-40a1-b522-571464b1bee2"},"attributes":{},"user":{"userId":"amzn1.ask.account.AGUEHIIGUAFBVDO37MD7KIXEECNN2E3LITFRR2OBMFPAA2PZDRHMBWID2JCFUHK2NQU2Q3DB2FFNJFW533A3ST463UZQS7GDY3B2UVVSRQCEVAPQAX44ODBZC657ZVXY3PTUDJCDU6DYWVOAPTKHYUGQING
๏
09:03:34
2017-04-10T09:03:34.075Z 91f3b0c1-1dcc-11e7-b0f1-85e057390cac Warning: Application ID is not set
๏
09:03:36
END RequestId: 91f3b0c1-1dcc-11e7-b0f1-85e057390cac
๏
09:03:36
REPORT RequestId: 91f3b0c1-1dcc-11e7-b0f1-85e057390cac Duration: 3001.35 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 36 MB
๏
09:03:36
2017-04-10T09:03:36.951Z 91f3b0c1-1dcc-11e7-b0f1-85e057390cac Task timed out after 3.00 seconds
๏
09:04:50
START RequestId: c0aac43e-1dcc-11e7-9e0b-75610f65f94e Version: $LATEST
๏
09:04:53
END RequestId: c0aac43e-1dcc-11e7-9e0b-75610f65f94e
๏
09:04:53
REPORT RequestId: c0aac43e-1dcc-11e7-9e0b-75610f65f94e Duration: 3000.73 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 15 MB
๏
09:04:53
2017-04-10T09:04:53.127Z c0aac43e-1dcc-11e7-9e0b-75610f65f94e Task timed out after 3.00 seconds
๏
09:04:58
START RequestId: c5dcdfac-1dcc-11e7-87a6-e55860640538 Version: $LATEST
๏
09:05:01
END RequestId: c5dcdfac-1dcc-11e7-87a6-e55860640538
๏
09:05:01
REPORT RequestId: c5dcdfac-1dcc-11e7-87a6-e55860640538 Duration: 3001.96 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 16 MB
Everyone, who can help me? Thanks a lot. Im using alexa-sdk version 1.0.8
I am seeing the same bug. Wondering it comes from sdk or the lambda itself
From my work on alexa-sdk I can't easily think of how this'd be caused by the SDK, but it's certainly not beyond the realms of possibility... Could you guys send some more details of how to simply replicate this issue (ideally the code that breaks it)? Can you make it break with just a simple setTimeout()?
@knowlsie Yeb
just a simple setTimeout
module.exports = {
'LetMeTimeoutIntent': function () {
this.emit('LetMeTimeout');
},
'LetMeTimeout': function () {
setTimeout(() => {
this.emit(':tell', 'should not be the answer');
}, 4000);
}
};
@nguyenthenguyen Lambda times out after 3 seconds, you can avoid this timeout by increasing the lambda function timeout (Configuration tab of the lambda function -> Advanced setting -> Timeout). This way your handle will complete execution. All your handlers will fail to complete execution if it takes more than 3 secs. Closing this issue, feel free to re-open if you need help.
Here's Lambda FAQ:
Q: How long can an AWS Lambda function execute?
All calls made to AWS Lambda must complete execution within 300 seconds. The default timeout is 3 seconds, but you can set the timeout to any value between 1 and 300 seconds.
@KrishFuriaAmazon thanks! I have another handler is working fine, but when LetMeTimeoutIntent executed, another handler timeout too.
I am not getting the exact picture here. What is other handler doing? Does that other handler depend on LetMeTimeoutIntent to finish execution?
I'm in the same boat as @KrishFuriaAmazon on this one. I've tried what I thought you meant (two sequential but separate requests from the same skill) but that seemed to work just fine. Can you give us more exact details of the code that's being run, or clearer details of what's going on?
@KrishFuriaAmazon @knowlsie
This is my lambda script:
'use strict';
let Alexa = require('alexa-sdk');
let logger = require('winston');
exports.handler = function (event, context, _callback) {
logger.info(JSON.stringify(event));
let alexa = Alexa.handler(event, context);
let timeoutHandler = {
'LetMeTimeoutIntent': function () {
this.emit('LetMeTimeout');
},
'LetMeTimeout': function () {
setTimeout(() => {
this.emit(':tell', 'should not be the answer');
}, 4000);
}
}
let okHandler = {
'OKIntent': function () {
this.emit('LetOK');
},
'LetOK': function () {
this.emit(':tell', 'I\'m OK' );
}
}
alexa.registerHandlers(
timeoutHandler,
okHandler
);
alexa.execute();
};
Intent Schema:
{
"intents": [
{
"intent": "LetMeTimeoutIntent"
},
{
"intent": "OKIntent"
}
]
}
Sample Utterances:
LetMeTimeoutIntent set timeout
OKIntent set ok
package.json
{
"name": "alexa_customskill_nguyen",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"alexa-sdk": "^1.0.9",
"winston": "^2.3.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
Step 1: set ok

Step 2: set timeout

Step 3: set ok

Lambda log:
08:53:38
START RequestId: d3f389ca-33cb-11e7-990a-df77bfc55a7c Version: $LATEST
๏
08:53:38
info: {"version":"1.0","session":{"new":true,"sessionId":"SessionId.cc531898-30d1-41db-bd83-a4d11179dcfb","application":{"applicationId":"amzn1.ask.skill.31bb9a14-2670-4017-82f2-84eba91e70e5"},"attributes":{},"user":{"userId":"amzn1.ask.account.AG2X2QXP4Z3WWAWDTUYDLUCNUNJOJHSRP4RF66GDAX6MR3WVBTCOQWSRYRV5CJBRC7L25Q2R3Z3IKHYXCFPYYNMCSGGVPZZQGYW6X5MGNF5LWQEVDFTGBZLNGQFQKN4NO3Z4YSSKQHCRUWEZYUPBFLWBJRW
๏
08:53:38
2017-05-08T08:53:38.573Z d3f389ca-33cb-11e7-990a-df77bfc55a7c Warning: Application ID is not set
๏
08:53:41
END RequestId: d3f389ca-33cb-11e7-990a-df77bfc55a7c
๏
08:53:41
REPORT RequestId: d3f389ca-33cb-11e7-990a-df77bfc55a7c Duration: 3000.17 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 37 MB
๏
08:53:41
2017-05-08T08:53:41.559Z d3f389ca-33cb-11e7-990a-df77bfc55a7c Task timed out after 3.00 seconds
๏
08:54:08
START RequestId: e6060091-33cb-11e7-b4e1-07eae92db7a6 Version: $LATEST
๏
08:54:11
END RequestId: e6060091-33cb-11e7-b4e1-07eae92db7a6
๏
08:54:11
REPORT RequestId: e6060091-33cb-11e7-b4e1-07eae92db7a6 Duration: 3002.17 ms Billed Duration: 3000 ms Memory Size: 128 MB Max Memory Used: 25 MB
๏
08:54:11
2017-05-08T08:54:11.875Z e6060091-33cb-11e7-b4e1-07eae92db7a6 Task timed out after 3.00 seconds
No newer events found at the moment. Retry.
@KrishFuriaAmazon Should we reopen this issues ?
I think your timeout in Lambda is still set to 3 seconds, which is the default. Because your setTimeout takes 4 seconds it will be terminated by lambda after 3 seconds. You can also see this in your logs.
You should change your timeout in Lambda, then it should work (AWS Console -> Lambda -> Functions -> "your alexa skill function" -> Configuration -> Advanced Settings -> Timeout). Code looks fine.
@feedm3 Thank for your reply.
Yes those are our intention to set lamdbda timeout = 3 second and LetMeTimeoutIntent timeout with 4 seconds.
We want to let the lambda continue to work after LetMeTimeoutIntent triggered. Why? Some intent may need very long processing, if some take longer than expected, we just let it failt. But the following request should continue to serve.
Current lambda dont work after timeout.
Is there any way to make one timeout dont loock the skill?
But I want OKIntent always work even if LetMeTimeoutIntent is timeout. In case, OKIntent not work after LetMeTimeoutIntent timeout
This is not possible. Lambda will kill any process that takes longer than the given timeout you set in your aws console.
@feedm3 Did you make sure Lambda will kill any process that takes longer than the given timeout ?
Could you try my lambda script and create alexa custom skill in example above ?. This happend only in custom skill, home skill working fine.
Most helpful comment
@nguyenthenguyen Lambda times out after 3 seconds, you can avoid this timeout by increasing the lambda function timeout (Configuration tab of the lambda function -> Advanced setting -> Timeout). This way your handle will complete execution. All your handlers will fail to complete execution if it takes more than 3 secs. Closing this issue, feel free to re-open if you need help.
Here's Lambda FAQ:
Q: How long can an AWS Lambda function execute?
All calls made to AWS Lambda must complete execution within 300 seconds. The default timeout is 3 seconds, but you can set the timeout to any value between 1 and 300 seconds.