firebase / firebase/firebase-js-sdk

Insufficient permissions error after the user is inactive for some time

Open
#7,590 18 comments 7 reactions 1 assignee Claimed by @wu-hui View on GitHub
api: firestore needs-attention question stack:Angular
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### Operating System

Mine: Windows 11; but happens on Macs as well

### Browser Version

Mine: Chrome ; but happens on all kinds of browsers of users

### Firebase SDK Version

9.22.2 ; angularFire 7.6.1

### Firebase SDK Product:

Analytics, AppCheck, Auth, Database, Firestore, Functions, Messaging, Performance, Storage

### Describe your project's tooling

Angular + AngularFire + rxjs + Angular-cli

### Describe the problem

This code shows how the user document that is stored in firestore is updated:

in authenticationService there is a line of code:
this.authentication$ = authState(this.auth);
that uses angularFire authState
image

the underlying function using angularFire docData
image

for a user (the same happens for many of our users) the logging looks like this:
image
so the user has the browser window open without actually using the application.

Because of the annoying "feature" of firestore to trigger connected documents every 30 minutes (and probably costing us a pretty penny) (also, see that it's not cleanly triggering every 30 minutes, it's very haphazardly), it's logged that the user document changed (but when we compare in the logging the 2 documents, it's clear the document didn't actually change).

And then, after an undeterminate amount of time, without a clear reason, suddenly together with such a new trigger firebase-js-sdk says there is a permissions error.

However logging makes clear there was actually no logout.

### Steps and code to reproduce issue

See the code above.
Reproduce: leave an amount of computers open for days and wake them up intermittently.

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.