6

I occasionally get this error in my application which utilizes firestore on the client frontend (JS Firebase/Firestore SDK library). This behaves like a rate limit issue I think, but my setup on Firebase is Blaze (pay as you go), so should I be seeing occasional issues like this?

During my development, clearing my cache / waiting it out / switching sessions or browsers seems to get around the issue. Not sure why it occasionally happens or why the ditsing around would solve it.

I currently have firebase.auth().signOut() implemented in my application, but whenever this happens, logging out and logging back in doesn't appear to solve the problem.

Here's my developer console stacktrace for the issue:

index.js:2177 Firestore error -> Error: Missing or insufficient permissions.
    at new FirestoreError (error.js:149)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromRpcStatus (serializer.js:93)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromWatchChange (serializer.js:536)
    at PersistentListenStream../node_modules/@firebase/firestore/dist/esm/src/remote/persistent_stream.js.PersistentListenStream.onMessage (persistent_stream.js:389)
    at persistent_stream.js:331
    at persistent_stream.js:306
    at async_queue.js:83
    at <anonymous>
__stack_frame_overlay_proxy_console__ @ index.js:2177
(anonymous) @ SideMenu.js:91
Promise rejected (async)
componentDidUpdate @ SideMenu.js:88
commitLifeCycles @ react-dom.development.js:11517
commitAllLifeCycles @ react-dom.development.js:12294
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
commitAllWork @ react-dom.development.js:12415
workLoop @ react-dom.development.js:12687
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
performWork @ react-dom.development.js:12800
scheduleUpdateImpl @ react-dom.development.js:13185
scheduleUpdate @ react-dom.development.js:13124
enqueueSetState @ react-dom.development.js:9646
./node_modules/react/cjs/react.development.js.ReactComponent.setState @ react.development.js:218
onStateChange @ connectAdvanced.js:205
dispatch @ createStore.js:173
(anonymous) @ Utils.js:162
Promise resolved (async)
(anonymous) @ Utils.js:146
getGoogleCloudProjectsWithPromise @ Utils.js:115
(anonymous) @ AppMenu.js:126
Promise resolved (async)
finalizeLogin @ AppMenu.js:123
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
(anonymous) @ auth.js:19
(anonymous) @ auth.js:142
(anonymous) @ auth.js:138
qd @ auth.js:45
G @ auth.js:44
ef @ auth.js:77
./node_modules/@firebase/auth/dist/auth.js.h.fc @ auth.js:75
./node_modules/@firebase/auth/dist/auth.js.h.zb @ auth.js:75
XMLHttpRequest.send (async)
(anonymous) @ VM7143:1
Ye @ auth.js:73
./node_modules/@firebase/auth/dist/auth.js.Ch.m @ auth.js:138
Kh @ auth.js:137
(anonymous) @ auth.js:142
z @ auth.js:19
Qh @ auth.js:142
(anonymous) @ auth.js:153
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
A @ auth.js:20
./node_modules/@firebase/auth/dist/auth.js.h.get @ auth.js:181
./node_modules/@firebase/auth/dist/auth.js.pj.get @ auth.js:184
ml @ auth.js:240
ll @ auth.js:239
ul @ auth.js:242
(anonymous) @ auth.js:286
./node_modules/@firebase/app/dist/esm/src/firebaseApp.js.FirebaseAppImpl._getService @ firebaseApp.js:116
FirebaseAppImpl.(anonymous function) @ firebaseApp.js:303
(anonymous) @ auth.js:286
(anonymous) @ firebaseApp.js:323
callAppHooks @ firebaseApp.js:316
initializeApp @ firebaseApp.js:247
./src/redux/factory.js @ factory.js:49
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/components/AppMenu.js @ Utils.js:170
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/App.js @ fetch.js:461
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/index.js @ Start.js:50
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
0 @ index.css?b74f:26
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
./node_modules/@firebase/app/dist/esm/index.js.Object.defineProperty.value @ bootstrap 6a68f7b55db27319f480:724
(anonymous) @ bundle.js:728
index.js:2177 Firestore error -> Error: Missing or insufficient permissions.
    at new FirestoreError (error.js:149)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromRpcStatus (serializer.js:93)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromWatchChange (serializer.js:536)
    at PersistentListenStream../node_modules/@firebase/firestore/dist/esm/src/remote/persistent_stream.js.PersistentListenStream.onMessage (persistent_stream.js:389)
    at persistent_stream.js:331
    at persistent_stream.js:306
    at async_queue.js:83
    at <anonymous>
__stack_frame_overlay_proxy_console__ @ index.js:2177
(anonymous) @ SideMenu.js:91
Promise rejected (async)
componentDidUpdate @ SideMenu.js:88
commitLifeCycles @ react-dom.development.js:11517
commitAllLifeCycles @ react-dom.development.js:12294
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
commitAllWork @ react-dom.development.js:12415
workLoop @ react-dom.development.js:12687
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
performWork @ react-dom.development.js:12800
scheduleUpdateImpl @ react-dom.development.js:13185
scheduleUpdate @ react-dom.development.js:13124
enqueueSetState @ react-dom.development.js:9646
./node_modules/react/cjs/react.development.js.ReactComponent.setState @ react.development.js:218
onStateChange @ connectAdvanced.js:205
dispatch @ createStore.js:173
(anonymous) @ AppMenu.js:128
Promise resolved (async)
(anonymous) @ AppMenu.js:126
Promise resolved (async)
finalizeLogin @ AppMenu.js:123
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
(anonymous) @ auth.js:19
(anonymous) @ auth.js:142
(anonymous) @ auth.js:138
qd @ auth.js:45
G @ auth.js:44
ef @ auth.js:77
./node_modules/@firebase/auth/dist/auth.js.h.fc @ auth.js:75
./node_modules/@firebase/auth/dist/auth.js.h.zb @ auth.js:75
XMLHttpRequest.send (async)
(anonymous) @ VM7143:1
Ye @ auth.js:73
./node_modules/@firebase/auth/dist/auth.js.Ch.m @ auth.js:138
Kh @ auth.js:137
(anonymous) @ auth.js:142
z @ auth.js:19
Qh @ auth.js:142
(anonymous) @ auth.js:153
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
A @ auth.js:20
./node_modules/@firebase/auth/dist/auth.js.h.get @ auth.js:181
./node_modules/@firebase/auth/dist/auth.js.pj.get @ auth.js:184
ml @ auth.js:240
ll @ auth.js:239
ul @ auth.js:242
(anonymous) @ auth.js:286
./node_modules/@firebase/app/dist/esm/src/firebaseApp.js.FirebaseAppImpl._getService @ firebaseApp.js:116
FirebaseAppImpl.(anonymous function) @ firebaseApp.js:303
(anonymous) @ auth.js:286
(anonymous) @ firebaseApp.js:323
callAppHooks @ firebaseApp.js:316
initializeApp @ firebaseApp.js:247
./src/redux/factory.js @ factory.js:49
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/components/AppMenu.js @ Utils.js:170
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/App.js @ fetch.js:461
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/index.js @ Start.js:50
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
0 @ index.css?b74f:26
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
./node_modules/@firebase/app/dist/esm/index.js.Object.defineProperty.value @ bootstrap 6a68f7b55db27319f480:724
(anonymous) @ bundle.js:728
index.js:2177 Firestore error -> Error: Missing or insufficient permissions.
    at new FirestoreError (error.js:149)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromRpcStatus (serializer.js:93)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromWatchChange (serializer.js:536)
    at PersistentListenStream../node_modules/@firebase/firestore/dist/esm/src/remote/persistent_stream.js.PersistentListenStream.onMessage (persistent_stream.js:389)
    at persistent_stream.js:331
    at persistent_stream.js:306
    at async_queue.js:83
    at <anonymous>
__stack_frame_overlay_proxy_console__ @ index.js:2177
(anonymous) @ SideMenu.js:91
Promise rejected (async)
componentDidUpdate @ SideMenu.js:88
commitLifeCycles @ react-dom.development.js:11517
commitAllLifeCycles @ react-dom.development.js:12294
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
commitAllWork @ react-dom.development.js:12415
workLoop @ react-dom.development.js:12687
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
performWork @ react-dom.development.js:12800
scheduleUpdateImpl @ react-dom.development.js:13185
scheduleUpdate @ react-dom.development.js:13124
enqueueSetState @ react-dom.development.js:9646
./node_modules/react/cjs/react.development.js.ReactComponent.setState @ react.development.js:218
onStateChange @ connectAdvanced.js:205
dispatch @ createStore.js:173
routeAfterLogin @ AppMenu.js:200
(anonymous) @ AppMenu.js:129
Promise resolved (async)
(anonymous) @ AppMenu.js:126
Promise resolved (async)
finalizeLogin @ AppMenu.js:123
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
(anonymous) @ auth.js:19
(anonymous) @ auth.js:142
(anonymous) @ auth.js:138
qd @ auth.js:45
G @ auth.js:44
ef @ auth.js:77
./node_modules/@firebase/auth/dist/auth.js.h.fc @ auth.js:75
./node_modules/@firebase/auth/dist/auth.js.h.zb @ auth.js:75
XMLHttpRequest.send (async)
(anonymous) @ VM7143:1
Ye @ auth.js:73
./node_modules/@firebase/auth/dist/auth.js.Ch.m @ auth.js:138
Kh @ auth.js:137
(anonymous) @ auth.js:142
z @ auth.js:19
Qh @ auth.js:142
(anonymous) @ auth.js:153
e.g @ auth.js:23
Yb @ auth.js:26
Ub @ auth.js:26
./node_modules/@firebase/auth/dist/auth.js.h.Mb @ auth.js:25
Cb @ auth.js:19
Promise resolved (async)
zb @ auth.js:18
yb @ auth.js:18
Vb @ auth.js:25
Eb @ auth.js:24
A @ auth.js:20
./node_modules/@firebase/auth/dist/auth.js.h.get @ auth.js:181
./node_modules/@firebase/auth/dist/auth.js.pj.get @ auth.js:184
ml @ auth.js:240
ll @ auth.js:239
ul @ auth.js:242
(anonymous) @ auth.js:286
./node_modules/@firebase/app/dist/esm/src/firebaseApp.js.FirebaseAppImpl._getService @ firebaseApp.js:116
FirebaseAppImpl.(anonymous function) @ firebaseApp.js:303
(anonymous) @ auth.js:286
(anonymous) @ firebaseApp.js:323
callAppHooks @ firebaseApp.js:316
initializeApp @ firebaseApp.js:247
./src/redux/factory.js @ factory.js:49
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/components/AppMenu.js @ Utils.js:170
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/App.js @ fetch.js:461
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
./src/index.js @ Start.js:50
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
fn @ bootstrap 6a68f7b55db27319f480:88
0 @ index.css?b74f:26
__webpack_require__ @ bootstrap 6a68f7b55db27319f480:678
./node_modules/@firebase/app/dist/esm/index.js.Object.defineProperty.value @ bootstrap 6a68f7b55db27319f480:724
(anonymous) @ bundle.js:728

Here are my datastore security rules:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;
    }
    match /dev/organizations/{orgId} {
        allow read;
      match /beacon-providers/{providerId} {
        // allow read, write: if auth.ordId = orgId
        // @TODO also check if user is an admin in the current org
        allow read, write: if orgId == 'incubation'
      }    
    }
    match /organizations/{orgId} {
      allow read, write: if orgId == 'incubation';
      match /beacon-providers {
        allow read, write;
        match /{providerId} {
                    //allow read: if resource.data.user_uid == request.auth.uid;
                    allow read,write;
        }
      }
    }
  }
}
Uche
  • 105
  • 1
  • 8
  • In the last case, I just cleared my browser cache, and that resolved the issue. Not sure if that helps with debugging. Still glad to get any help / answers. – Uche Nov 12 '17 at 12:28
  • Did you fix the issue clearly? – wonsuc Nov 12 '17 at 19:15
  • This is happening for me as well. To add to the mix, I don't think this is related to the client SDK. I'm working on a project which has both web and react-native component, this issue occasionally happens on both. So this has to do something with firestore itself. – sowdri Nov 12 '17 at 21:31
  • @wonsuc No, I wasn't able to determine a fix from the clearing of the cache. Far as I can tell, that just resets the state of my application and perhaps that impacts the circumstances required to reproduce - but that doesn't rule out coincidence. Especially considering the above corroboration, I still consider this an issue. – Uche Dec 22 '17 at 20:08
  • @uch I hope [this answer](https://stackoverflow.com/a/47283435/4729203) helps you. – wonsuc Dec 23 '17 at 02:15
  • 1
    @uch have you solved this? Are you unsubscribing after all of your calls to onSnapshot? – chez.mosey Feb 27 '18 at 12:03

0 Answers0