Comments (7)
I have a branch on my fork with implementation and would happily create a PR.
from serverless.
This would be a huge help for me and my team. We are constantly dealing with Rate exceeded
issues resulting in needed manual intervention.
from serverless.
Commenting for visibility as my team has to manually redeploy serverless stacks on rate-exceeded pipelines everytime.
from serverless.
Bump - this would be really helpful for my team
from serverless.
This would be the solution needed in our team. We occasionally face an exceeding rate, which sometimes causes rollback issues after the update fails. Please take this PR into consideration as soon as possible to make our deployments smoothly. Thanks
from serverless.
Would love to see this go in as well. These rate limits are very bad to deal with when trying to use serverless at scale
from serverless.
Looks like the serverless community is not interested in merging the fix for issue #12400.
For those who face this issue and want to apply a quick fix, here is the plugin that we ended up using (credits to @ben-exa)
const ServerlessError = require('serverless/lib/serverless-error');
class AWSExponentialBackoff {
constructor(serverless, options) {
this.serverless = serverless;
this.options = options;
this.hooks = {
initialize: this.enhanceAwsRequest.bind(this),
};
}
enhanceAwsRequest() {
const awsProvider = this.serverless.getProvider('aws');
const originalRequest = awsProvider.request.bind(awsProvider);
awsProvider.request = async (service, method, params, options) => {
let attempts = 0;
const MAX_RETRIES = 5;
const BASE_BACKOFF = 5000; // milliseconds
const EXPONENTIAL_FACTOR = 2;
const retryRequest = async () => {
try {
return await originalRequest(service, method, params, options);
} catch (error) {
const { providerError } = error;
this.serverless.cli.log(
`Caught error: ${JSON.stringify(error, null, 2)}`,
);
if (
attempts < MAX_RETRIES &&
providerError &&
((providerError.retryable &&
providerError.statusCode !== 403 &&
providerError.code !== 'CredentialsError' &&
providerError.code !== 'ExpiredTokenException') ||
providerError.statusCode === 429)
) {
attempts++;
const backOff =
BASE_BACKOFF * Math.pow(EXPONENTIAL_FACTOR, attempts - 1);
this.serverless.cli.log(
`Error occurred: ${error.message}. Retrying after ${
backOff / 1000
} seconds...`,
);
await new Promise((resolve) => setTimeout(resolve, backOff));
return retryRequest();
}
throw new ServerlessError(
`Failed after ${attempts} retries: ${error.message}`,
error.code,
);
}
};
return retryRequest();
};
}
}
module.exports = AWSExponentialBackoff;
You can just use it in your serverless definition as follows:
plugins:
# your plugin list
- ./serverless/plugins/aws-exponential-backoff.js
from serverless.
Related Issues (20)
- [Kafka Trigger] Ease multiple topics consumption HOT 1
- Unable to Disable esbuild Bundling in Serverless4: 'Cannot use "external" without "bundle"' HOT 4
- V4 how to login in a non-interactive way? HOT 7
- V4: dev mode throws error when function invoked HOT 7
- run serverless info when running serverless dev HOT 7
- V4 Broken error reporting: functionHandler is not defined HOT 10
- V4: ${opt:stage} does not resolve when using "-s" but does when using "--stage" HOT 6
- serverless config credentials HOT 4
- V4 - Include original error message after our custom error messages when resolving AWS Credentials HOT 1
- V4: Unrecognized command “plugin install” v4.0.26 HOT 6
- Serverless4: Using esbuild's "packages: external" flag doesn't seem to work HOT 3
- Serverless4: Unable to Ensure that the Prisma libquery Engine and schema.prisma are Included in my Bundle HOT 7
- Support MFA Prompt when using an AWS Profile
- V4 progress spinner conflicts with plugins HOT 1
- Error: Cannot find module 'serverless/lib/serverless-error' While installing the appsync plugin HOT 2
- Dev Mode instruments all functions across multiple services if run in parent folder
- Ensure Bref works with Serverless Framework V.4 HOT 1
- Ensure Lift works with Serverless Framework V.4 HOT 7
- v3: Error: Cannot use 'publicReadAccess' property on a bucket without allowing bucket-level public access through 'blockPublicAceess' property. HOT 2
- Resolvers error regarding `replace`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless.