Here is my query
const query = messagesRef.where('members', 'in', [`${currentUserId}`]).orderBy('createdAt')
I have created an index as well.
This is the error I get
Error: {"code":"failed-precondition","name":"FirebaseError"}
Which I assume is usually an index thing
Yes, the failed-precondition can be due to a missing index. It can also be manually thrown by a user though with any user-defined description, typically from within a Firebase Function. The category is the only thing that must confine to the convention:
https://cloud.google.com/datastore/docs/concepts/errors
Here's one example of such error common in App-Checked Firebase Functions:
if (context.app == undefined) {
throw new functions.https.HttpsError(
'failed-precondition',
'The function must be called from an App Check verified app.')
}
You may want to check your Function Logs to get the actual error description. If the issue happens locally, then your firestore-debug.log file should contain some useful information. Just to be certain it's actually an index issue or not.
If the issue is happening only on production, you may want to verify the contents of your firestore.indexes.json and compare to what's inside the Firebase Console under https://console.firebase.google.com/u/0/project/<PROJECT-NAME>/firestore/indexes.
If it's actually an index issue, there will be a URL provided inside the logs that you can click which will generate the index for you inside Firestore:
https://firebase.google.com/docs/firestore/query-data/indexing?authuser=0&hl=en#create_a_missing_index_through_an_error_message
I hope this helps track down the issue! I used failed-precondition for several different error types, some unrelated to Firestore or indexes.
Related
I'm making a bot that could go though my clients website and get details for the products they have and since the products' pricing, availability, promos & etc. changes multiple times in a week then I need to update my spreadsheet too manually for the rest of my team to use. Finding those changes for each product is my job which is very prone to error. If only they could provide me with an API, life would have much been easier but no.
My client told me that I've been spamming their error report and tripping their alarms on their server error logs and the functions/files they found are the helper functions that I injected into the DOMWorld on their site using page.addScriptTag('./client/helper.js') and the helper functions inside that file (wasn't sure if that is all they found but so far they have only mentioned that file and the functions inside it).
const product_name = await page.$eval('#product-name', product => {
getProductName(product )
})
The getProductName() function comes from this file ./client/helper.js.
//This simply removes unwanted characters
function getProductName(product ) {
return product.innerHTML.replace(/[\s]{2}/g,'')
}
I wasn't aware that they could see this as I thought puppeteer runs locally on the client-side, on my computer only.
I have few ideas that could make this go undetected and silence their alarms and errors.
First would be to NOT use page.addScriptTag('./client/helper.js') at all and put the codes of this file straight into the main file then do further processes after getting the innerHTML.
const product_name = await page.$eval('#product-name', product => {
return product.innerHTML
})
const final_product_name = product_name.replace(/[\s]{2}/g,'')
This does work but my only concerns is if will this still be detectable as I am still running an anonymous function inside page.$eval(). That I am still trying to find out if my client complains again.
So my question really is..
Will removing page.addScriptTag() and using anonymous function be undetectable?
is there any other way to scrape string in the DOMWorld ? (if it turns out that anonymous function still triggers errors)
Is this because i'm using headless chrome?
Thank you for reading.
just a brief question. I've been struggling to figure out what this error in javascript actually means: "Timed out retrying: expected null to deeply equal [Array (1)]
I'm basically working on a LocalStorage Shopping Cart and my code is actually based on this video: https://www.youtube.com/watch?v=uR3r3GJvQDY&t=417s
It's pretty much very identical. The code perfectly works on my system without any errors but as soon as I upload it to my university's server on which the code undergoes certain tests I receive the above-named error. It also doesn't really indicate in which line of the code the error is happening. My instructor only told me this usually happens when the cart should exist in the localStorage, however, it doesn't which means the localStorage returns NULL to the system.
For reference to the code please check: https://gist.github.com/prof3ssorSt3v3/3e15d06a8128d6ca7deaa831a7a1e52b
So, we basically create a cart called contents and we never remove empty the LocalStorage at any point in the code. How can the LocalStorage return null at some point then and cause the error?
For the init function I have this:
init(){
//check localStorage and initialize the contents of CART.contents
let _contents = localStorage.getItem(cart.KEY);
if(_contents){
cart.contents = JSON.parse(_contents);
}
else{
cart.contents = [];
cart.sync();
}
},
Thank you for your help in advance!
I'm creating a e-commerce with Vue & Firebase. Trying to add some cart information from the current logged in user. Strange thing is at the very first time information saved perfectly. When I trying to add some again. That dosent work and show this error.
Uncaught FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: undefined
So I have to refresh that page. Then it work again. I cant understand where is the problem.
Note: If I try to add any other value instead of cart. then it works fine.
checkoutLoggedInUser(){
var db = firebase.firestore();
var user = firebase.auth().currentUser;
db.collection("orders").add({
user_id:user.uid,
cart:this.$store.getters.cart
})
this.$store.commit('emptyCart')
this.$router.push({ name: 'Home'})
}
That error message is saying that one of the fields you're trying to write to a document is undefined in JavaScript. Check the values that you're passing by using console.log or using a debugger to figure out which one is undefined, then change your code to pass something else, or omit the field entirely.
Also bear in mind that the error message is referencing a call to DocumentReference.set(), but the code you're showing is calling DocumentReference.add(), so the error might be in a different location.
Running the example mentioned in the title, there is no output after the "---Storage---" line. According to my understanding, there should be a null_radix stored at the created address. (running gives no exceptions) please correct me if I’m wrong!
[update]
At the following part of the example at the runTx function I've noticed that we refresh the createdAddress variable at every transaction even though it doesn't register a new contract. Therefore it leaves us with the loss of our contract's address and the readStorage function won't print any output.
I've fixed it by checking the createdAddress property for null before saving the value.
if (returns.createdAddress) {
createdAddress = results.createdAddress
console.log('address created: ' + createdAddress.toString('hex'))
}
I am having difficulty in distinguishing between if a PFUser is being updated or if it is being saved for the first time. I implemented the solution found on parse.com here. However, it is not working as explained in the answer found at the link. I always get a false regardless of if it is on the creation or an update. Here is the code that I have implemented.
Parse.Cloud.afterSave(Parse.User, function(request) {
Parse.Cloud.useMasterKey();
//this error log prints false regardless of if the user is signing up.
// or having a key updated.
console.error(request.object.existed());
if (!request.object.existed()) {
//This is on sign up, the user has not existed prior.
//This doesn't work. This block of code is always run.
}
else {
//This is supposedly when the user is having a key updated.
//Unfortunately, this code is never run regardless.
}
)}
This code does not behave as I expect it to because the request.object.existed() always returns false. I think this may have to do that this is saving a PFUser and not some generic PFObject. Is there something I am missing using request.object.existed() on a PFUser afterSave? Thanks.
This seems to be an unresolved Parse cloud bug
Possible workaround is to check the difference between create and update times to see if your object is being updated or is being created.