angular / angular/angularfire

setPersistence in AngularFire _BrowserLocalPersistence cannot be invoked without 'new'`

Open
#3,550 3 comments 5 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.8k
Forks
2.2k
Avg merge
22h 28m
Merged PRs (30d)
6

Description

Problem
The setPersistence method does not work when imported from @angular/fire/auth, leading to a TypeError. However, it works when imported from firebase/auth.

Error
When using the import from @angular/fire/auth, the following error is encountered:

`ERROR TypeError: Class constructor _BrowserLocalPersistence cannot be invoked without 'new'`
Code Example

- Non-functional:
`import { setPersistence, browserLocalPersistence } from '@angular/fire/auth';`
`await setPersistence(this.auth, browserLocalPersistence);`

- Functional:
`import { setPersistence, browserLocalPersistence } from 'firebase/auth';`
`await setPersistence(this.auth, browserLocalPersistence);`

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure using the @angular/fire/auth imports and compare it with the working firebase/auth imports shown in the issue. Trace the authentication entry points and verify that setPersistence with browserLocalPersistence works through @angular/fire/auth without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, firebase, typescript
Domain
authentication
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
43/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.