useFirestoreDocData & useFirestoreDoc won't throw a promise on permission denied
See original GitHub issueVersion info
React: 16.12.0
Firebase: 7.5.2
ReactFire: 2.0.0-canary.1fce6b9
Test case
I want to use role based authentication on documents, so when a document is successfully read in the app and then I change the access of that user, the listener throws an error instead of a Promise.
const CompanyCheck: React.FC = ({ children }) => {
const { companyId, setCompany } = useCompanyContext();
const firestore: Firebase['Firestore'] = useFirestore();
const companyRef = useRef(
firestore()
.collection('companies')
.doc(companyId)
);
useEffect(() => {
companyRef.current = firestore()
.collection('companies')
.doc(companyId);
}, [companyId, firestore]);
// This won't throw a promise on permission changes after successfull read.
const companyDoc = useFirestoreDocData<Company>(companyRef.current);
useEffect(() => {
setCompany(companyDoc);
}, [companyDoc, setCompany]);
return <>{children}</>;
};
Steps to reproduce
Use a correct example of read operation with role access, then once the data is displayed remove the access to the document and error boundary won’t catch any error.
Expected behavior
Throw a promise like when initial read fails so ErrorBoundary can catch the error.
Actual behavior
Don’t throw a Promise and error can’t be handled. Error message is: ‘permission-denied’
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
What is the proper way to handle "Permission Denied" when a ...
I have written rules for Firestore, however, when a document does not exist it throws a "Missing or Insufficient Permissions error".
Read more >How to fix Firestore Error: PERMISSION_DENIED - Medium
The caller does not have permission to execute the specified ... the above Exception is thrown containing the following error message:.
Read more >cloud_firestore/permission-denied flutter - You.com | The AI ...
Describe the bug I can't get access to Cloud Firestore database for my Web application. It throws me an error [cloud_firestore/permission-denied] Missing or ......
Read more >Permission Denied in Firestore - Anycodings.com
In the future, anycodings_firebase-security promise rejections that are not handled will anycodings_firebase-security terminate the Node.js ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s what I meant. After changing the access an error is triggered due to permission denied but the Error Boundary is not catching any error and because of that the fallback is not showing.
Thanks a lot for your reply and effort @jhuleatt. I apologize if I wasn’t clear enough with the issue.