简短而甜蜜:
Google
登录弹出窗口(键盘命令或点击 X)时,为什么收到 (auth/popup-closed-by-user)
错误几乎延迟了 7 秒?.这里有什么想法吗?我希望它立即抛出错误......出于多种原因。
我已经多次测试过这一点,但它总是延迟。在 MacBook Pro 2021 上运行 Safari 17.2.1
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.10.0/firebase-app.js'
import { getAuth, signInWithPopup, GoogleAuthProvider, getAdditionalUserInfo } from 'https://www.gstatic.com/firebasejs/10.10.0/firebase-auth.js'
const firebaseConfig = {
apiKey: "********",
authDomain: "********"
}
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const provider = new GoogleAuthProvider()
export function signInWithGoogle(callback) {
auth.languageCode = 'it'
signInWithPopup(auth, provider)
.then((result) => {
const credential = GoogleAuthProvider.credentialFromResult(result)
const token = credential.accessToken
const user = result.user
const { isNewUser } = getAdditionalUserInfo(result)
callback(null, user, isNewUser)
}).catch((error) => {
const errorCode = error.code
const errorMessage = error.message
const email = error.customData.email
const credential = GoogleAuthProvider.credentialFromError(error)
console.log(errorMessage)
callback(error, null, false)
})
}
从这个github问题中,轮询过程检查弹出窗口是否关闭,并将其超时从2秒增加到8秒以解决firefox中的问题,因此出现延迟。