You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which gets back a successful response with the token, but the [email protected] = user line never completes, so the source.setResult call never occurs. Hence the hang.
@Throws(IOException::class)
override fun onResponse(call: Call, response: Response) {
val body = response.body()?.use { it.string() }
if (!response.isSuccessful) {
signOutAndThrowInvalidUserException(body.orEmpty(), "token API returned an error: $body")
} else {
jsonParser.parseToJsonElement(body!!).jsonObject.apply {
val user = FirebaseUserImpl(app, this, user.isAnonymous)
if (user.claims["aud"] != app.options.projectId) {
signOutAndThrowInvalidUserException(
user.claims.toString(),
"Project ID's do not match ${user.claims["aud"]} != ${app.options.projectId}"
)
} else {
[email protected] = user
source.setResult(user)
}
}
}
}
My Kobweb code is actually using firebase-kotlin-sdk 2.1.0 and the latest Kobweb with Kotlin 2.
The text was updated successfully, but these errors were encountered:
Actually I just realised there is code behind the FirebaseAuth.user assignment and the problem is that it uses:
GlobalScope.launch(Dispatchers.Main) {
Which is obviously a bad thing to do, as GlobalScope is one of the things that they say never to use... plus the documentation on Dispatchers.Main for JVM says Android / Swing / JavaFX, so I'm guessing there is no implementation that would work on the Kobweb API backend JVM.
On Kobweb this just hangs and none of the code in this section runs:
GlobalScope.launch(Dispatchers.Main) {
if (prev?.uid != value?.uid) {
authStateListeners.forEach { l -> l.onAuthStateChanged(this@FirebaseAuth) }
}
if (prev?.idToken != value?.idToken) {
val result = InternalTokenResult(value?.idToken)
for (listener in internalIdTokenListeners) {
Log.i("FirebaseAuth", "Calling onIdTokenChanged for ${value?.uid} on listener $listener")
listener.onIdTokenChanged(result)
}
for (listener in idTokenListeners) {
listener.onIdTokenChanged(this@FirebaseAuth)
}
}
}
Actually as a quick hack I have taken a local copy of firebase-java-sdk and removed all the Dispatchers.Main in FirebaseAuth.kt and this has got me further.
So I really think you need to reasses the use of GlobalScope.launch(Dispatchers.Main) and replace them with something that is more cross platform friendly.
This is running on a Kobweb API call under JVM, so there could be some different initialisation in there.
Stepping through the code, it appears that the enqueueRefreshTokenCall is hanging on this line:
It goes through the successful response and then sets up the refresh token call...
Which calls the enqueueRefreshTokenCall...
Which gets back a successful response with the token, but the [email protected] = user line never completes, so the source.setResult call never occurs. Hence the hang.
My Kobweb code is actually using firebase-kotlin-sdk 2.1.0 and the latest Kobweb with Kotlin 2.
The text was updated successfully, but these errors were encountered: