QFix: Continue processing other workspaces in case of error (#8923)

Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
Artyom Savchenko 2025-05-14 13:35:24 +07:00 committed by GitHub
parent ff2465ad12
commit 95838cf8a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 22 deletions

View File

@ -187,6 +187,7 @@ class KeyValueClientImpl implements KeyValueClient {
errMessage.includes('network')
if (!isNetworkError || timeout < Date.now()) {
console.error(`KVS request failed for url ${url}`, err.message)
throw err
}

View File

@ -93,35 +93,39 @@ export class GmailController {
this.ctx.info('Workspaces with integrations', { count: workspaceIds.size })
for (const workspace of workspaceIds) {
const wsToken = serviceToken(workspace)
const accountClient = getAccountClient(wsToken)
try {
const wsToken = serviceToken(workspace)
const accountClient = getAccountClient(wsToken)
const tokens = await getWorkspaceTokens(accountClient, workspace)
await limiter.add(async () => {
const info = await accountClient.getWorkspaceInfo()
const tokens = await getWorkspaceTokens(accountClient, workspace)
await limiter.add(async () => {
const info = await accountClient.getWorkspaceInfo()
if (info === undefined) {
this.ctx.info('workspace not found', { workspaceUuid: workspace })
return
}
if (!isActiveMode(info.mode)) {
this.ctx.info('workspace is not active', { workspaceUuid: workspace })
return
}
this.ctx.info('Use stored tokens', { count: tokens.length })
const startPromise = this.startWorkspace(workspace, tokens)
const timeoutPromise = new Promise<void>((resolve) => {
setTimeout(() => {
resolve()
}, 60000)
if (info === undefined) {
this.ctx.info('workspace not found', { workspaceUuid: workspace })
return
}
if (!isActiveMode(info.mode)) {
this.ctx.info('workspace is not active', { workspaceUuid: workspace })
return
}
this.ctx.info('Use stored tokens', { count: tokens.length })
const startPromise = this.startWorkspace(workspace, tokens)
const timeoutPromise = new Promise<void>((resolve) => {
setTimeout(() => {
resolve()
}, 60000)
})
await Promise.race([startPromise, timeoutPromise])
})
await Promise.race([startPromise, timeoutPromise])
})
} catch (err: any) {
this.ctx.error('Failed to create workspace client', { workspaceUuid: workspace, error: err.message })
}
}
await limiter.waitProcessing()
} catch (err: any) {
this.ctx.error('Failed to start existing integrations', err)
this.ctx.error('Failed to start existing integrations', { error: err.message })
}
}