@@ -71,20 +71,44 @@ async function runSuite(name) {
7171 const { restoreConsole } = interceptConsoleWithStackMapping ( ) ;
7272
7373 try {
74- // Start a web server that serves VS Code in a browser, run the tests
75- await runTests ( {
76- headless : true , // pass false to see VS Code UI
77- browserType : "chromium" ,
78- extensionDevelopmentPath,
79- extensionTestsPath,
80- folderPath : workspacePath ,
81- quality : "stable" ,
82- printServerLog : verbose ,
83- verbose,
84- waitForDebugger : waitForDebugger
85- ? Number ( waitForDebugger . slice ( attachArgName . length ) )
86- : undefined ,
87- } ) ;
74+ const maxRetries = 3 ;
75+ for ( let attempt = 1 ; attempt <= maxRetries ; attempt ++ ) {
76+ try {
77+ // Start a web server that serves VS Code in a browser, run the tests
78+ await runTests ( {
79+ headless : true , // pass false to see VS Code UI
80+ browserType : "chromium" ,
81+ extensionDevelopmentPath,
82+ extensionTestsPath,
83+ folderPath : workspacePath ,
84+ quality : "stable" ,
85+ printServerLog : verbose ,
86+ verbose,
87+ waitForDebugger : waitForDebugger
88+ ? Number ( waitForDebugger . slice ( attachArgName . length ) )
89+ : undefined ,
90+ } ) ;
91+ break ;
92+ } catch ( err ) {
93+ // Until the @vscode /test-web library is more robust, we have our own retry logic for VS Code download errors.
94+ // We want to be conservative about what errors we retry on, to avoid masking real test failures.
95+ //
96+ // Pattern for network errors adapted from
97+ // https://github.com/microsoft/vscode/blob/5b8296c45664992e9730529b8ea48a00fb4f4417/build/azure-pipelines/common/retry.ts#L13
98+ if (
99+ maxRetries === attempt ||
100+ ! ( err instanceof Error ) ||
101+ ! / C l i e n t n e t w o r k s o c k e t d i s c o n n e c t e d | s o c k e t h a n g u p | E C O N N R E S E T / i. test (
102+ err . message ,
103+ )
104+ ) {
105+ throw err ;
106+ }
107+ console . warn (
108+ `Attempt ${ attempt } failed with a network error: ${ err . message } ` ,
109+ ) ;
110+ }
111+ }
88112 } finally {
89113 restoreConsole ( ) ;
90114 }
0 commit comments