mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
fix(AWS HTTP API): Recognize max timeout as 30s not 29s (#10119)
This commit is contained in:
parent
7e246690b5
commit
e3e02fe8e2
@ -611,29 +611,29 @@ Object.defineProperties(
|
||||
const functionTimeout =
|
||||
Number(functionData.timeout) || Number(this.serverless.service.provider.timeout) || 6;
|
||||
|
||||
if (functionTimeout > 29) {
|
||||
if (functionTimeout > 30) {
|
||||
logWarning(
|
||||
`Function (${functionName}) timeout setting (${functionTimeout}) is greater than ` +
|
||||
'maximum allowed timeout for HTTP API endpoint (29s). ' +
|
||||
'maximum allowed timeout for HTTP API endpoint (30s). ' +
|
||||
'This may introduce a situation where endpoint times out ' +
|
||||
'for a succesful lambda invocation.'
|
||||
);
|
||||
log.warning(
|
||||
`Function (${functionName}) timeout setting (${functionTimeout}) is greater than ` +
|
||||
'maximum allowed timeout for HTTP API endpoint (29s). ' +
|
||||
'maximum allowed timeout for HTTP API endpoint (30s). ' +
|
||||
'This may introduce a situation where endpoint times out ' +
|
||||
'for a succesful lambda invocation.'
|
||||
);
|
||||
} else if (functionTimeout === 29) {
|
||||
} else if (functionTimeout === 30) {
|
||||
logWarning(
|
||||
`Function (${functionName}) timeout setting (${functionTimeout}) may not provide ` +
|
||||
'enough room to process an HTTP API request (of which timeout is limited to 29s). ' +
|
||||
'enough room to process an HTTP API request (of which timeout is limited to 30s). ' +
|
||||
'This may introduce a situation where endpoint times out ' +
|
||||
'for a succesful lambda invocation.'
|
||||
);
|
||||
log.warning(
|
||||
`Function (${functionName}) timeout setting (${functionTimeout}) may not provide ` +
|
||||
'enough room to process an HTTP API request (of which timeout is limited to 29s). ' +
|
||||
'enough room to process an HTTP API request (of which timeout is limited to 30s). ' +
|
||||
'This may introduce a situation where endpoint times out ' +
|
||||
'for a succesful lambda invocation.'
|
||||
);
|
||||
@ -642,7 +642,7 @@ Object.defineProperties(
|
||||
// It's a margin needed for some side processing time on AWS side.
|
||||
// Otherwise there's a risk of observing 503 status for successfully resolved invocation
|
||||
// (which just fit function timeout setting)
|
||||
routeTargetData.timeout = Math.min(functionTimeout + 0.5, 29);
|
||||
routeTargetData.timeout = Math.min(functionTimeout + 0.5, 30);
|
||||
}
|
||||
}),
|
||||
compileIntegration: d(function (routeTargetData) {
|
||||
|
||||
@ -45,6 +45,16 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => {
|
||||
handler: 'index.handler',
|
||||
events: [{ httpApi: 'ANY /payload' }],
|
||||
},
|
||||
customTimeout: {
|
||||
handler: 'index.handler',
|
||||
events: [{ httpApi: 'ANY /custom-timeout' }],
|
||||
timeout: 29,
|
||||
},
|
||||
maxTimeout: {
|
||||
handler: 'index.handler',
|
||||
events: [{ httpApi: 'ANY /max-timeout' }],
|
||||
timeout: 30,
|
||||
},
|
||||
},
|
||||
},
|
||||
}).then(({ awsNaming, cfTemplate }) => {
|
||||
@ -119,11 +129,21 @@ describe('lib/plugins/aws/package/compile/events/httpApi.test.js', () => {
|
||||
expect(resource.Properties.RouteKey).to.equal(routeKey);
|
||||
});
|
||||
|
||||
it('should ensure higher timeout than function', () => {
|
||||
it('should ensure higher timeout than function default value', () => {
|
||||
const resource = cfResources[naming.getHttpApiIntegrationLogicalId('foo')];
|
||||
expect(resource.Properties.TimeoutInMillis).to.equal(6500);
|
||||
});
|
||||
|
||||
it('should provide 0.5s time margin to custom function integration timeout', () => {
|
||||
const resource = cfResources[naming.getHttpApiIntegrationLogicalId('customTimeout')];
|
||||
expect(resource.Properties.TimeoutInMillis).to.equal(29500);
|
||||
});
|
||||
|
||||
it('should limit function maximum integration timeout to 30s', () => {
|
||||
const resource = cfResources[naming.getHttpApiIntegrationLogicalId('maxTimeout')];
|
||||
expect(resource.Properties.TimeoutInMillis).to.equal(30000);
|
||||
});
|
||||
|
||||
it('should configure lambda permissions', () => {
|
||||
const resource = cfResources[naming.getLambdaHttpApiPermissionLogicalId('foo')];
|
||||
expect(resource.Type).to.equal('AWS::Lambda::Permission');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user