Do not retry for some kind of errors in Github (#9055)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2025-05-22 16:54:24 +07:00 committed by GitHub
parent 39d1c0a76a
commit 6d4337febb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 44 additions and 7 deletions

View File

@ -365,6 +365,11 @@ export async function OnToDoUpdate (txes: Tx[], control: TriggerControl): Promis
const description = updTx.operations.description const description = updTx.operations.description
const visibility = updTx.operations.visibility const visibility = updTx.operations.visibility
if (doneOn != null) { if (doneOn != null) {
const todo = (await control.findAll(control.ctx, time.class.ToDo, { _id: updTx.objectId }))[0]
if (todo === undefined || todo.doneOn != null) {
// Do not process already processed todos.
continue
}
const events = await control.findAll(control.ctx, time.class.WorkSlot, { attachedTo: updTx.objectId }) const events = await control.findAll(control.ctx, time.class.WorkSlot, { attachedTo: updTx.objectId })
const resEvents: WorkSlot[] = [] const resEvents: WorkSlot[] = []
for (const event of events) { for (const event of events) {
@ -405,10 +410,7 @@ export async function OnToDoUpdate (txes: Tx[], control: TriggerControl): Promis
resEvents.push(event) resEvents.push(event)
} }
} }
const todo = (await control.findAll(control.ctx, time.class.ToDo, { _id: updTx.objectId }))[0]
if (todo === undefined) {
continue
}
const funcs = control.hierarchy.classHierarchyMixin<Class<Doc>, OnToDo>( const funcs = control.hierarchy.classHierarchyMixin<Class<Doc>, OnToDo>(
todo.attachedToClass, todo.attachedToClass,
serverTime.mixin.OnToDo serverTime.mixin.OnToDo

View File

@ -728,7 +728,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
if (allResolved) { if (allResolved) {
// We need to complete or remove todo, in case all are resolved. // We need to complete or remove todo, in case all are resolved.
if (!Array.from(approvedOrChangesRequested.values()).includes('CHANGES_REQUESTED')) { if (!Array.from(approvedOrChangesRequested.values()).includes('CHANGES_REQUESTED')) {
const todos = allTodos.filter((it) => it.purpose === 'fix') const todos = allTodos.filter((it) => it.purpose === 'fix' && it.doneOn == null)
for (const t of todos) { for (const t of todos) {
await this.markDoneOrDeleteTodo(t) await this.markDoneOrDeleteTodo(t)
} }
@ -853,7 +853,7 @@ export class PullRequestSyncManager extends IssueSyncManagerBase implements DocS
private async markDoneOrDeleteTodo (td: WithLookup<GithubTodo>): Promise<void> { private async markDoneOrDeleteTodo (td: WithLookup<GithubTodo>): Promise<void> {
// Let's mark as done in any case // Let's mark as done in any case
await this.client.update(td, { await this.client.diffUpdate(td, {
doneOn: Date.now() doneOn: Date.now()
}) })
} }

View File

@ -1156,6 +1156,30 @@ export class GithubWorker implements IntegrationManager {
state: wrongAuthentications state: wrongAuthentications
}) })
} }
const fixWrongLastGithubAccount = 'migrate-lastGithubAccount'
if (migrations.find((it) => it.plugin === githubId && it.state === fixWrongLastGithubAccount) === undefined) {
while (true) {
const syncInfos = await this.client.findAll(
github.class.DocSyncInfo,
{ lastGithubUser: { $ne: null } },
{ limit: 500 }
)
if (syncInfos.length === 0) {
break
}
const ops = this._client.apply()
for (const auth of syncInfos) {
await ops.update(auth, { lastGithubUser: null })
}
await ops.commit()
}
await derivedClient.createDoc(core.class.MigrationState, core.space.Configuration, {
plugin: githubId,
state: fixWrongLastGithubAccount
})
}
} }
async syncAndWait (): Promise<void> { async syncAndWait (): Promise<void> {
@ -1606,7 +1630,18 @@ export class GithubWorker implements IntegrationManager {
} }
const ops = derivedClient.apply() const ops = derivedClient.apply()
for (const d of withError) { for (const d of withError) {
await ops.update(d, { error: null, needSync: '' }) const errStr = JSON.stringify(d.error)
// Skip this error's and not retry
const skipError =
errStr.includes('Bad credentials') ||
errStr.includes('Resource not accessible by integration') ||
errStr.includes('does not have permission to update') ||
errStr.includes('State cannot be changed') ||
errStr.includes('Not Found') ||
errStr.includes('Could not resolve to a node with the global') ||
errStr.includes('Body is too long, Body is too long')
await ops.update(d, { error: null, needSync: skipError ? githubSyncVersion : '' })
} }
await ops.commit() await ops.commit()
} }