angular / angular/angularfire

[Auth Guard - BUG] canActivate auth guard causes blank screen after cache clear with multiple tabs opens.

Ouverte
#3,691 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
TypeScript
Étoiles
7.8k
Forks
2.2k
Merge moyen
22 h 28 min
PR mergées (30 j)
6

Description

If using the canActivate auth guard (with spread syntax), If you have more than 1 tab open of the same app, and then you clear the cache by using the browser in one of the tabs, and try to refresh, it causes a blank screen, which resolves after you close the other open tab.

steps to reproduce:

versions:
"@angular/common": "^20.3.0",
"@angular/compiler": "^20.3.0",
"@angular/core": "^20.3.0",
"@angular/fire": "^20.0.1",
"@angular/forms": "^20.3.0",
"@angular/platform-browser": "^20.3.0",
"@angular/router": "^20.3.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"

steps to reproduce:
1. Create new project
2. install angular fire
3. setup authentication and firebase project
4. utilize the ...canActivate auth guard like below.
5. open two tabs of the same page.
6. in one of them, clear the cache (by using the button close to the url in chrome for ex)
7. refresh
8. blank screen.
9. verify that if you close the second tab, then the first one loads correctly.

```TS
const redirectTeste1 = () => redirectLoggedInTo('test2');
const redirectTeste2 = () => redirectUnauthorizedTo('teste1');

export const routes: Routes = [
{ path: '', redirectTo: 'teste1', pathMatch: 'full' },

{
path: 'teste1',
component: Test1,
...canActivate(redirectTeste1),
},

{
path: 'teste2',
component: Test2,
...canActivate(redirectTeste2),
},
];
```

lmk if this is somehow a user error, but with such a barebones configuration I think is a legitimate bug.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la configuration minimale de l’authentification AngularFire décrite dans l’issue, en utilisant le guard canActivate avec redirectLoggedInTo et redirectUnauthorizedTo. Reproduisez le comportement avec deux onglets, videz le cache dans l’un d’eux et actualisez-le. C’est terminé lorsque l’onglet actualisé se charge normalement au lieu d’afficher un écran vide tandis que l’autre onglet reste ouvert.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, firebase, typescript
Domaine
authentication, frontend
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
À clarifier
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.