@@ -10,6 +10,7 @@ import { promptForConfirmOrDetails, sleep, transformCustomDomainProps } from '..
1010import loadComponent from '@serverless-devs/load-component' ;
1111import { IInputs as _IInputs } from '@serverless-devs/component-interface' ;
1212import { FC3_DOMAIN_COMPONENT_NAME } from '../../constant' ;
13+ import { DisableFunctionInvocationRequest } from '@alicloud/fc20230330' ;
1314
1415export default class Remove {
1516 private region : IRegion ;
@@ -451,17 +452,18 @@ export default class Remove {
451452 `Remove function ${ this . functionName } failed with ProvisionConfigExist error, retrying...` ,
452453 ) ;
453454
455+ const retryCount = 25 ;
454456 // 重试 20 次,每次间隔 2 秒
455- for ( let i = 1 ; i <= 20 ; i ++ ) {
456- logger . info ( `Retry attempt ${ i } /20 ...` ) ;
457+ for ( let i = 1 ; i <= retryCount ; i ++ ) {
458+ logger . info ( `Retry attempt ${ i } /${ retryCount } ...` ) ;
457459 await sleep ( 2 ) ;
458460
459461 try {
460462 await this . fcSdk . fc20230330Client . deleteFunction ( this . functionName ) ;
461463 logger . info ( `Function ${ this . functionName } removed successfully on retry attempt ${ i } ` ) ;
462464 break ;
463465 } catch ( retryEx ) {
464- if ( i === 20 ) {
466+ if ( i === retryCount ) {
465467 // 最后一次重试仍然失败
466468 logger . error (
467469 `Remove function ${ this . functionName } error after 20 retries: ${ retryEx . message } ` ,
@@ -475,6 +477,13 @@ export default class Remove {
475477 throw retryEx ;
476478 }
477479
480+ if ( i === 5 ) {
481+ logger . warn ( `Remove function ${ this . functionName } error after 5 retries, disable function invocation.` ) ;
482+ const disableFunctionInvocationRequest = new DisableFunctionInvocationRequest ( { reason : 'functionai-delete' , abortOngoingRequest : true } )
483+ const res = await this . fcSdk . fc20230330Client . disableFunctionInvocation ( this . functionName , disableFunctionInvocationRequest ) ;
484+ logger . debug ( `DisableFunctionInvocation: ${ ( JSON . stringify ( res , null , 2 ) ) } ` )
485+ }
486+
478487 // 如果是 ProvisionConfigExist 错误,继续重试
479488 logger . warn (
480489 `Remove function ${ this . functionName } still failed with ProvisionConfigExist error, continuing retries...` ,
0 commit comments