Merge pull request #11115 from Budibase/fix/BUDI-7242
Removing bb-alert for user sync failure
This commit is contained in:
commit
86a32f3c39
|
@ -0,0 +1,14 @@
|
||||||
|
export function checkErrorCode(error: any, code: number) {
|
||||||
|
const stringCode = code.toString()
|
||||||
|
if (typeof error === "object") {
|
||||||
|
return error.status === code || error.message?.includes(stringCode)
|
||||||
|
} else if (typeof error === "number") {
|
||||||
|
return error === code
|
||||||
|
} else if (typeof error === "string") {
|
||||||
|
return error.includes(stringCode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isDocumentConflictError(error: any) {
|
||||||
|
return checkErrorCode(error, 409)
|
||||||
|
}
|
|
@ -9,3 +9,4 @@ export * from "../constants/db"
|
||||||
export { getGlobalDBName, baseGlobalDBName } from "../context"
|
export { getGlobalDBName, baseGlobalDBName } from "../context"
|
||||||
export * from "./lucene"
|
export * from "./lucene"
|
||||||
export * as searchIndexes from "./searchIndexes"
|
export * as searchIndexes from "./searchIndexes"
|
||||||
|
export * from "./errors"
|
||||||
|
|
|
@ -21,6 +21,6 @@ export function logAlertWithInfo(
|
||||||
logAlert(message, error)
|
logAlert(message, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logWarn(message: string) {
|
export function logWarn(message: string, e?: any) {
|
||||||
console.warn(`bb-warn: ${message}`)
|
console.warn(`bb-warn: ${message}`, e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,5 @@
|
||||||
import env from "../../../environment"
|
import env from "../../../environment"
|
||||||
import {
|
import { db as dbCore, context, logging, roles } from "@budibase/backend-core"
|
||||||
db as dbCore,
|
|
||||||
context,
|
|
||||||
docUpdates,
|
|
||||||
constants,
|
|
||||||
logging,
|
|
||||||
roles,
|
|
||||||
} from "@budibase/backend-core"
|
|
||||||
import { User, ContextUser, UserGroup } from "@budibase/types"
|
import { User, ContextUser, UserGroup } from "@budibase/types"
|
||||||
import { sdk as proSdk } from "@budibase/pro"
|
import { sdk as proSdk } from "@budibase/pro"
|
||||||
import sdk from "../../"
|
import sdk from "../../"
|
||||||
|
@ -107,9 +100,11 @@ export async function syncUsersToAllApps(userIds: string[]) {
|
||||||
}
|
}
|
||||||
const resp = await Promise.allSettled(promises)
|
const resp = await Promise.allSettled(promises)
|
||||||
const failed = resp.filter(promise => promise.status === "rejected")
|
const failed = resp.filter(promise => promise.status === "rejected")
|
||||||
if (failed.length > 0) {
|
const reasons = failed
|
||||||
const reasons = failed.map(fail => (fail as PromiseRejectedResult).reason)
|
.map(fail => (fail as PromiseRejectedResult).reason)
|
||||||
logging.logAlert("Failed to sync users to apps", reasons)
|
.filter(reason => !dbCore.isDocumentConflictError(reason))
|
||||||
|
if (reasons.length > 0) {
|
||||||
|
logging.logWarn("Failed to sync users to apps", reasons)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue