firebase / firebase/firebase-tools

Auth emulator resets anonymous auth when restarted

Open
#5,278 1 comment 0 reactions 0 assignees View on GitHub
emulators: auth type: feature request
Dominant language
TypeScript
Stars
4.5k
Forks
1.3k
Avg merge
1d 12h
Merged PRs (30d)
84

Description

### [REQUIRED] Environment info

**firebase-tools:** 11.16.0

**Platform:** Windows

### [REQUIRED] Test case

Set up a new project with the auth emulator enabled, and a web client that calls `app.auth().signInAnonymously()`.

### [REQUIRED] Steps to reproduce

1. Start the auth emulator.
2. Sign in from the web client. Note the `uid` of the user that was created.
3. Reload the client and note that the `uid` of the (anonymous) user remains the same.
4. Stop the auth emulator.
5. Start the auth emulator.
6. Reload the client and observe the `uid` of the user.

(Setting the emulator to export/import data doesn't affect the outcome.)

### [REQUIRED] Expected behavior

The `uid` should remain the same if `signInAnonymously()` is called from the same browser, and the local state (IndexedDB, etc.) hasn't been cleared.

### [REQUIRED] Actual behavior

A new user with a fresh `uid` is created. You can observe that the `POST` to `http://localhost:9099/www.googleapis.com/identitytoolkit/v3/relyingparty/getAccountInfo?key=demo-dev` with the stored `idToken` fails with error code 400, causing a request to `signupNewUser` to be issued.

It's not clear whether this is expected behavior or not, but it doesn't match the behavior in production and makes it hard (impossible?) to keep a consistent anonymous user identity when testing in dev over a longer period of time.

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.