firebase / firebase/firebase-admin-node

Find or delete non-existing UID results to prevent an uncacheable error.

未关闭
#2,845 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
api: auth
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
3 天 10 小时
30 天内合并 PR
16

描述

Platform:
* Operating System version: MacOs - Darwin 23.6.0 arm64 arm
* Firebase SDK version: 11.11.1
* Firebase Product: Firebase Auth
* Bun version: 1.2.2 (Don't think is related)
* NPM version: 10.8.2

Problem:
Whenever I try to find a user that doesn't exist or delete a uid that doesn't exist it thorws an error that breaks the function and is not cachable for some reaons, and its very weird behavirous that im not able to handle, i tried to use try catch, and then catch, but still the same. This has no steep to reprpoduce the error, its default behaviour.

Code:
```ts
import { Firebase } from '@/libs/firebase'
import { Console } from '@/helpers/logs'

const admin = await Firebase()

const DeleteFirebaseAccount = async (uid: string): Promise => {
try {
const userExists = await admin.auth().getUser(uid)
if (userExists) await admin.auth().deleteUser(uid)

return true
}

catch (error) {
Console.Error('DeleteFirebaseAccount', error)
return false
}
}

export default DeleteFirebaseAccount
```

The error:
```
class FirebaseError extends Error {
29 | constructor(errorInfo) {
30 | super(errorInfo.message);
^
error: There is no user record corresponding to the provided identifier.
errorInfo: {
code: "auth/user-not-found",
message: "There is no user record corresponding to the provided identifier.",
},
codePrefix: "auth",
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。