Skip to content

Commit 4533fcd

Browse files
philnashdkundel
authored andcommitted
fix(serverless-api): retries on 429 error for POST request
Got by default does not retry on POST requests. This changes the retry behaviour to retry across all of the methods that the API uses (GET, POST and DELETE) but only for 429 errors. chore(prettier): re-adds prettierrc to the top level
1 parent 7a6a49f commit 4533fcd

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "es5",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": true,
6+
"parser": "typescript"
7+
}

packages/serverless-api/src/client.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
259259
this
260260
);
261261
const foundFunction = availableFunctions.find(
262-
(fn) => fn.friendly_name === filterByFunction
262+
fn => fn.friendly_name === filterByFunction
263263
);
264264
if (!foundFunction) {
265265
throw new Error('Invalid Function Name or SID');
@@ -297,7 +297,7 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
297297
this
298298
);
299299
const foundFunction = availableFunctions.find(
300-
(fn) => fn.friendly_name === filterByFunction
300+
fn => fn.friendly_name === filterByFunction
301301
);
302302
if (!foundFunction) {
303303
throw new Error('Invalid Function Name or SID');
@@ -506,7 +506,7 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
506506
message: `Uploading ${functions.length} Functions`,
507507
});
508508
const functionVersions = await Promise.all(
509-
functionResources.map((fn) => {
509+
functionResources.map(fn => {
510510
return uploadFunction(fn, serviceSid as string, this, this.config);
511511
})
512512
);
@@ -530,7 +530,7 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
530530
message: `Uploading ${assets.length} Assets`,
531531
});
532532
const assetVersions = await Promise.all(
533-
assetResources.map((asset) => {
533+
assetResources.map(asset => {
534534
return uploadAsset(asset, serviceSid as string, this, this.config);
535535
})
536536
);
@@ -662,6 +662,8 @@ export class TwilioServerlessApiClient extends events.EventEmitter {
662662
): Promise<unknown> {
663663
options.retry = {
664664
limit: this.config.retryLimit || RETRY_LIMIT,
665+
methods: ['GET', 'POST', 'DELETE'],
666+
statusCodes: [429],
665667
};
666668
return this.limit(() => this.client[method](path, options));
667669
}

0 commit comments

Comments
 (0)