File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,25 @@ class Cos {
3434 throw new Error ( JSON . stringify ( e ) )
3535 }
3636 } else {
37- throw new Error ( JSON . stringify ( e ) )
37+ // cos在云函数中可能出现ECONNRESET错误,没办法具体定位,初步猜测是客户端问题,是函数启动网络还没准备好,这个还不确定,所以在这里做兼容
38+ if ( JSON . stringify ( e ) . includes ( 'ECONNRESET' ) ) {
39+ // 检查bucket是否存在
40+ const headHandler = util . promisify ( this . cosClient . headBucket . bind ( this . cosClient ) )
41+ try {
42+ const isHave = await headHandler ( createParams )
43+ if ( isHave . statusCode == 200 ) {
44+ if ( ! inputs . force ) {
45+ throw new Error ( 'BucketAlreadyExists and BucketAlreadyOwnedByYou' )
46+ }
47+ } else {
48+ throw new Error ( 'Could not find this bucket' )
49+ }
50+ } catch ( err ) {
51+ throw new Error ( JSON . stringify ( err ) )
52+ }
53+ } else {
54+ throw new Error ( JSON . stringify ( e ) )
55+ }
3856 }
3957 }
4058 }
Original file line number Diff line number Diff line change @@ -311,12 +311,12 @@ class Scf {
311311 thisTrigger [ 'parameters' ] [ 'filter' ] &&
312312 thisTrigger [ 'parameters' ] [ 'filter' ] [ 'prefix' ]
313313 ? thisTrigger [ 'parameters' ] [ 'filter' ] [ 'prefix' ]
314- : '' ,
314+ : String ( '' ) ,
315315 Suffix :
316316 thisTrigger [ 'parameters' ] [ 'filter' ] &&
317317 thisTrigger [ 'parameters' ] [ 'filter' ] [ 'suffix' ]
318318 ? thisTrigger [ 'parameters' ] [ 'filter' ] [ 'suffix' ]
319- : ''
319+ : String ( '' )
320320 }
321321 } )
322322 trigger . Enable = inputs . events [ i ] [ 'cos' ] [ 'parameters' ] [ 'enable' ] ? 'OPEN' : 'CLOSE'
You can’t perform that action at this time.
0 commit comments