Skip to content

Commit

Permalink
add timeouts to protect against cross-region latency
Browse files Browse the repository at this point in the history
  • Loading branch information
homeyjd committed Mar 23, 2019
1 parent 826891a commit 100b7cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cloudformation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Resources:
Role: !GetAtt FunctionRole.Arn
Runtime: nodejs8.10
MemorySize: 256
Timeout: 10
Timeout: 15 # Cross-region metrics lookup requires at least 10s
Code:
S3Bucket: !Sub 'aws-to-slack-${AWS::Region}'
S3Key: release.zip
Expand Down
9 changes: 7 additions & 2 deletions src/parsers/cloudwatch/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ class AwsCloudWatchChart {
this.height = _.get(config, "height", 250);
this.metrics = [];

const clientOpt = {};
const clientOpt = {
// Cross-region lookups requires at least 10s
httpOptions: { timeout: 10000 },
};
if (this.region) {
clientOpt.region = this.region;
}
Expand Down Expand Up @@ -225,7 +228,9 @@ class AwsCloudWatchChart {
metricNamespace: query.Namespace,
limit: 1,
};
const clientOpt = {};
const clientOpt = {
httpOptions: { timeout: 10000 },
};
if (this.region) {
clientOpt.region = this.region;
}
Expand Down

0 comments on commit 100b7cf

Please sign in to comment.