Skip to content

Commit 100b7cf

Browse files
committed
add timeouts to protect against cross-region latency
1 parent 826891a commit 100b7cf

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

cloudformation.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Resources:
5050
Role: !GetAtt FunctionRole.Arn
5151
Runtime: nodejs8.10
5252
MemorySize: 256
53-
Timeout: 10
53+
Timeout: 15 # Cross-region metrics lookup requires at least 10s
5454
Code:
5555
S3Bucket: !Sub 'aws-to-slack-${AWS::Region}'
5656
S3Key: release.zip

src/parsers/cloudwatch/chart.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ class AwsCloudWatchChart {
149149
this.height = _.get(config, "height", 250);
150150
this.metrics = [];
151151

152-
const clientOpt = {};
152+
const clientOpt = {
153+
// Cross-region lookups requires at least 10s
154+
httpOptions: { timeout: 10000 },
155+
};
153156
if (this.region) {
154157
clientOpt.region = this.region;
155158
}
@@ -225,7 +228,9 @@ class AwsCloudWatchChart {
225228
metricNamespace: query.Namespace,
226229
limit: 1,
227230
};
228-
const clientOpt = {};
231+
const clientOpt = {
232+
httpOptions: { timeout: 10000 },
233+
};
229234
if (this.region) {
230235
clientOpt.region = this.region;
231236
}

0 commit comments

Comments
 (0)