Skip to content

Commit 1fe13c6

Browse files
authored
Merge pull request #116 from devsapp/fix-until-function
fix: adjust container accelerated timeout and handle timeout state
2 parents 2f4ea41 + f4ade60 commit 1fe13c6

3 files changed

Lines changed: 17 additions & 6 deletions

File tree

src/default/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const FC_INSTANCE_EXEC_TIMEOUT: number = parseInt(
8282
);
8383

8484
export const FC_CONTAINER_ACCELERATED_TIMEOUT: number = parseInt(
85-
process.env.FC_CONTAINER_ACCELERATED_TIMEOUT || '3',
85+
process.env.FC_CONTAINER_ACCELERATED_TIMEOUT || '40',
8686
10,
8787
);
8888

src/resources/fc/error-code.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,10 @@ export const isFailedState = (ex) => {
4444
}
4545
return false;
4646
};
47+
48+
export const isFunctionStateWaitTimedOut = (ex) => {
49+
if (_.startsWith(ex.message, 'retry to wait function state ok timeout')) {
50+
return true;
51+
}
52+
return false;
53+
};

src/resources/fc/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
isSlsNotExistException,
5353
isInvalidArgument,
5454
isFailedState,
55+
isFunctionStateWaitTimedOut,
5556
} from './error-code';
5657
import { isCustomContainerRuntime, isCustomRuntime, computeLocalAuto } from './impl/utils';
5758
import replaceFunctionConfig from './impl/replace-function-config';
@@ -79,10 +80,8 @@ export default class FC extends FC_Client {
7980
new Date().getTime() - startTime > minute * 60 * 1000;
8081

8182
// 默认重试 3 min
82-
let maxRetryContainerAcceleratedTime = FC_CONTAINER_ACCELERATED_TIMEOUT;
83-
if (isAppCenter()) {
84-
maxRetryContainerAcceleratedTime = FC_CONTAINER_ACCELERATED_TIMEOUT * 7;
85-
}
83+
const maxRetryContainerAcceleratedTime = FC_CONTAINER_ACCELERATED_TIMEOUT;
84+
8685
const retryContainerAccelerated = FC.isCustomContainerRuntime(config.runtime);
8786
// 部署镜像需要重试 3min, 直到达到!(State == Pending || LastUpdateStatus == InProgress)
8887
if (retryContainerAccelerated) {
@@ -308,7 +307,12 @@ export default class FC extends FC_Client {
308307
throw ex;
309308
}
310309
retryInterval = 5;
311-
} else if (isAccessDenied(ex) || isInvalidArgument(ex) || isFailedState(ex)) {
310+
} else if (
311+
isAccessDenied(ex) ||
312+
isInvalidArgument(ex) ||
313+
isFailedState(ex) ||
314+
isFunctionStateWaitTimedOut(ex)
315+
) {
312316
throw ex;
313317
} else if (retry > FC_DEPLOY_RETRY_COUNT) {
314318
throw ex;

0 commit comments

Comments
 (0)