mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-24 17:05:42 +00:00
QFix: Continue processing other workspaces in case of error (#8923)
Signed-off-by: Artem Savchenko <armisav@gmail.com>
This commit is contained in:
parent
ff2465ad12
commit
95838cf8a5
@ -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
|
||||
}
|
||||
|
||||
|
@ -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 })
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user