firebase / firebase/firebase-ios-sdk

Bug: Auth.auth().currentUser Returns Nil on Some Devices Despite Available User Data.

Open
#13,231 51 comments 8 reactions 1 assignee Assigned to @ncooke3 View on GitHub
api: auth
Dominant language
C++
Stars
6.7k
Forks
1.8k
Avg merge
2d 14h
Merged PRs (30d)
72

Description

### Description

The `Auth.auth().currentUser` property consistently returns nil on specific devices, even though a logged-in user is expected. In contrast, the `getStoredUser(forAccessGroup:)` method intermittently returns a user object, suggesting that the user data is accessible. The behavior remains consistent across device lifecycles, where the method either returns a user object or does not, without variation. The whole extension works on a concurrent environment.

Also functions are working authenticated despite `Auth.auth().currentUser` is nil. State listener does not change the rules, I mean, it does not change Auth.auth().currentUser, and also does not return other than nil on those cases Auth.auth().currentUser is nil.

### Reproducing the issue

----
I'm not sure, but maybe it more reproducible when updates happens. Because what I saw in some cases is:

`Auth.auth().currentUser` is nil and `getStoredUser(forAccessGroup:)` is also nil until the user enters on the app, then getStoredUser(forAccessGroup:) returns a value in the extension.

Even sometimes both `Auth.auth().currentUser` `getStoredUser(forAccessGroup:)` are nil until the extension restart.

Could be any kind of deadlock trying to get the keychain element?

### Firebase SDK Version

10.25

### Xcode Version

15.2

### Installation Method

Swift Package Manager

### Firebase Product(s)

Authentication

### Targeted Platforms

iOS, macCatalyst

### Relevant Log Output

_No response_

### If using Swift Package Manager, the project's Package.resolved

Expand Package.resolved snippet

```json

Replace this line with the contents of your Package.resolved.

```

### If using CocoaPods, the project's Podfile.lock

Expand Podfile.lock snippet

```yml

Replace this line with the contents of your Podfile.lock!

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.