Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timeout on AWS Lambda #31

Open
dancju opened this issue Jan 8, 2019 · 5 comments
Open

Timeout on AWS Lambda #31

dancju opened this issue Jan 8, 2019 · 5 comments

Comments

@dancju
Copy link

dancju commented Jan 8, 2019

It works fine on my local environment (my laptop). But the same code on AWS Lambda would cause a timeout exception, and no log event was created in the target log group.

'use strict';
const bunyan = require('bunyan');
const bunyanCloudWatch = require('bunyan-cloudwatch');
const PrettyStream = require('bunyan-prettystream');
const os = require('os');

const prettyStdOut = new PrettyStream();
prettyStdOut.pipe(process.stdout);

const prettyStdErr = new PrettyStream();
prettyStdErr.pipe(process.stderr);

module.exports = bunyan.createLogger({
  name: 'nexus',
  streams: [
    {
      level: 'error',
      stream: bunyanCloudWatch({
        logGroupName: 'herald',
        logStreamName: os.hostname() + '-' + Date.now(),
      }),
      type: 'raw',
    },
    {
      level: 'debug',
      type: 'raw',
      stream: prettyStdOut,
      reemitErrorEvents: true,
    },
  ],
});

CloudWatch log group of the Lambda function (not the target log group)

REPORT RequestId: 5de9d2b8-1296-11e9-a802-8bf9a9168cb1	Duration: 10010.15 ms	Billed Duration: 10000 ms Memory Size: 128 MB	Max Memory Used: 53 MB	
2019-01-07T16:07:54.192Z 5de9d2b8-1296-11e9-a802-8bf9a9168cb1 Task timed out after 10.01 seconds
2019-01-07T16:07:54.748Z	5de9d2b8-1296-11e9-a802-8bf9a9168cb1	Getting value AWS_REGION from environmental variable with value us-west-2 overriding us-west-2
@dancju
Copy link
Author

dancju commented Jan 8, 2019

If I remove the first item from the stream: [ array, the timeout issue would vanish.

@dancju
Copy link
Author

dancju commented Jan 8, 2019

It's not because of the missing region parameter.
On my local environment, the awk-sdk could load credentials and region from the config file. On the Lambda environment, it should be same case. Actually I tried specifying the region and didn't work.

@MatthewDeLeon-ops
Copy link

@mirkokiefer! have you had a chance to acknowledge his problem its been a whole year and half since he created this issue. I went to this issue because @mirkokiefer I'm having the same issue getting error: End - Error:
error: {
"errorMessage": "Task timed out after 3.00 seconds",
"errorType": "TimeoutError",
"stackTrace": [
"new TimeoutError (/usr/local/lib/node_modules/lambda-local/build/lib/utils.js:109:28)",
"Context. (/usr/local/lib/node_modules/lambda-local/build/lib/context.js:110:19)",
"ontimeout (timers.js:482:11)",
"tryOnTimeout (timers.js:317:5)",
"Timer.listOnTimeout (timers.js:277:5)". However, if you use async,await,return, and callback in any combination the timeout issue gets resolved but then Bunyan "fails to post the data logs to the cloudwatch group.

@MatthewDeLeon-ops
Copy link

MatthewDeLeon-ops commented Jul 14, 2020

@Nerddan were you able to resolve your timeout issue? When I run my code I get that error I mentioned to @mirkokiefer but the code will post to my aws cloudwatch group and stream. fixing the error I got with the combination just fixes timeout but not the issue of it not posting to the stream. Additionally, I'm surprised how bunyan-cloudwatch hasn't been updated in over 5 years completely wow.... I cant find any docs for troubleshooting or even how to kill the stream event.

@dancju
Copy link
Author

dancju commented Jul 22, 2020

@Ilikecoding145 I no longer work on that project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants