提交 66aab342 编写于 作者: J João Moreno

retry createAsset sproc due to ECONNRESET

上级 c4d77ea6
......@@ -66,6 +66,20 @@ function getEnv(name: string): string {
return result;
}
async function retry<T>(fn: () => Promise<T>): Promise<T> {
for (let run = 1; run <= 10; run++) {
try {
return await fn();
} catch (err) {
if (!/ECONNRESET/.test(err.message)) {
throw err;
}
}
}
throw new Error('Retried too many times');
}
async function main(): Promise<void> {
const [, , platform, type, fileName, filePath] = process.argv;
const quality = getEnv('VSCODE_QUALITY');
......@@ -121,7 +135,7 @@ async function main(): Promise<void> {
const client = new CosmosClient({ endpoint: process.env['AZURE_DOCUMENTDB_ENDPOINT']!, key: process.env['AZURE_DOCUMENTDB_MASTERKEY'] });
const scripts = client.database('builds').container(quality).scripts;
await scripts.storedProcedure('createAsset').execute('', [commit, asset, true]);
await retry(() => scripts.storedProcedure('createAsset').execute('', [commit, asset, true]));
}
main().then(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册