Skip to content

Commit dd96f73

Browse files
authored
Merge branch 'main' into ngrok-custom-config
2 parents 9ec13d5 + 4533fcd commit dd96f73

File tree

5 files changed

+25
-6
lines changed

5 files changed

+25
-6
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
}

packages/twilio-run/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ twilio-run --inspect
152152
# Exposes the Twilio functions via ngrok to share them
153153
twilio-run --ngrok
154154

155+
# Exposes the Twilio functions via ngrok using a custom subdomain (requires a paid-for ngrok account)
156+
twilio-run --ngrok=subdomain
157+
155158
# Uses a custom project ngrok config and named tunnel to expose the functions via ngrok
156159
twilio-run --ngrok --ngrok-config=./ngrok.yml --ngrok-name=example
157160
```

packages/twilio-run/src/commands/activate.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
sharedCliOptions,
2222
} from './shared';
2323
import { CliInfo } from './types';
24+
import { ClientApiError } from '@twilio-labs/serverless-api/dist/utils/error';
2425

2526
const debug = getDebugFunction('twilio-run:activate');
2627

@@ -33,7 +34,12 @@ function handleError(err: Error, spinner: Ora) {
3334
if (spinner) {
3435
if (err.name === 'TwilioApiError') {
3536
spinner.fail('Failed promoting build.');
36-
logApiError(logger, err);
37+
const clientApiError = err as ClientApiError;
38+
if (clientApiError.code === 20409) {
39+
clientApiError.message +=
40+
'\n\nThis is probably because you are trying to promote a build to an environment where it is already live. Try promoting the build to a different environment or choosing a different build to promote to this environment.';
41+
}
42+
logApiError(logger, clientApiError);
3743
} else {
3844
spinner.fail(err.message);
3945
}

packages/twilio-run/src/commands/start.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ export const cliInfo: CliInfo = {
138138
},
139139
ngrok: {
140140
type: 'string',
141-
describe: 'Uses ngrok to create and outfacing url',
141+
describe:
142+
'Uses ngrok to create a public url. Pass a string to set the subdomain (requires a paid-for ngrok account).',
142143
},
143144
'ngrok-config': {
144145
type: 'string',

0 commit comments

Comments
 (0)