@@ -31,7 +31,7 @@ const testWorkspace = path.join(jsv3_root, "..", "canary-aws-sdk-js-v3");
3131 } ) ;
3232
3333 verdaccioFork = await runRegistry ( [ "-c" , path . join ( jsv3_root , "verdaccio" , "config.yaml" ) ] ) ;
34- await localPublishChangedPackages ( jsv3_root ) ;
34+ await retry ( ( ) => localPublishChangedPackages ( jsv3_root ) ) ;
3535
3636 await spawnProcess ( "npm" , [ "init" , "-y" ] , { cwd : testWorkspace } ) ;
3737 await spawnProcess ( "npm" , [ "install" , `@aws-sdk/client-sts@ci` , "--registry" , "http://localhost:4873/" ] , {
@@ -71,6 +71,18 @@ function runRegistry(args = [], childOptions = {}) {
7171 } ) ;
7272}
7373
74+ async function retry ( fn , attempts = 3 ) {
75+ for ( let i = 0 ; i < attempts ; i ++ ) {
76+ try {
77+ return await fn ( ) ;
78+ } catch ( error ) {
79+ if ( i === attempts - 1 ) throw error ;
80+ console . log ( `Retry ${ i + 1 } /${ attempts } failed, retrying...` ) ;
81+ await new Promise ( ( resolve ) => setTimeout ( resolve , 2000 ) ) ;
82+ }
83+ }
84+ }
85+
7486async function localPublishChangedPackages ( root ) {
7587 await spawnProcess ( "rm" , [ "-rf" , "verdaccio/storage" ] , { cwd : root , stdio : "inherit" } ) ;
7688
@@ -96,5 +108,5 @@ async function localPublishChangedPackages(root) {
96108 "--dist-tag" ,
97109 "ci" ,
98110 ] ;
99- await spawnProcess ( "npx" , args , { cwd : root , stdio : "inherit" } ) ;
111+ await retry ( ( ) => spawnProcess ( "npx" , args , { cwd : root , stdio : "inherit" } ) ) ;
100112}
0 commit comments