Adding warning back in for non-409 errors of user sync.

This commit is contained in:
mike12345567 2023-07-03 16:00:33 +01:00
parent 76bce0be1a
commit 4e560a1f32
3 changed files with 19 additions and 9 deletions

View File

@ -0,0 +1,9 @@
export function is409Error(error: any) {
if (typeof error === "object") {
return error.status === 409 || error.message?.includes("409")
} else if (typeof error === "number") {
return error === 409
} else if (typeof error === "string") {
return error.includes("409")
}
}

View File

@ -9,3 +9,4 @@ export * from "../constants/db"
export { getGlobalDBName, baseGlobalDBName } from "../context"
export * from "./lucene"
export * as searchIndexes from "./searchIndexes"
export * from "./errors"

View File

@ -1,12 +1,5 @@
import env from "../../../environment"
import {
db as dbCore,
context,
docUpdates,
constants,
logging,
roles,
} from "@budibase/backend-core"
import { db as dbCore, context, logging, roles } from "@budibase/backend-core"
import { User, ContextUser, UserGroup } from "@budibase/types"
import { sdk as proSdk } from "@budibase/pro"
import sdk from "../../"
@ -105,7 +98,14 @@ export async function syncUsersToAllApps(userIds: string[]) {
promises.push(syncUsersToApp(appId, finalUsers, groups))
}
}
return await Promise.allSettled(promises)
const resp = await Promise.allSettled(promises)
const failed = resp.filter(promise => promise.status === "rejected")
const reasons = failed
.map(fail => (fail as PromiseRejectedResult).reason)
.filter(reason => !dbCore.is409Error(reason))
if (reasons.length > 0) {
logging.logWarn("Failed to sync users to apps", reasons)
}
}
export async function syncApp(