Skip to content

Commit ae43fed

Browse files
author
Mine Starks
committed
retry on vscode test network failures
1 parent aeb4cbc commit ae43fed

File tree

1 file changed

+38
-14
lines changed

1 file changed

+38
-14
lines changed

source/vscode/test/runTests.mjs

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
!/Client network socket disconnected|socket hang up|ECONNRESET/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

Comments
 (0)