Comments (3)
Hey @skillitzimberg, thanks for reaching out and for providing a detailed report. Let me know if I may have misunderstood anything, but from what I can gather, you are encountering an Error: 9 FAILED_PRECONDITION.
error in your scheduled function.
It’s likely that indexes for the query you’re trying to run haven't been generated yet, or are being overwritten by a different one. My guess is that it’s the latter since you mentioned it breaks after deployments.
After deploying the firebase.indexes.json
you shared, I tried modifying the code snippet you provided to instead use a descending order and no error were raised:
async function _clearOldDocuments() {
const date = Date.now() - 600000; // 10 min
const reports = await admin.firestore()
.collectionGroup("reports")
.where("generateDate", "<", new Date(date))
.orderBy("generateDate", "desc")
.get();
for (let doc of reports.docs) {
console.log(doc.data())
}
// const batch = admin.firestore().batch();
// reports.forEach((d) => batch.delete(d.ref));
// await batch.commit();
}
Since a descending order worked, I’m guessing the query is using an ascending order. That said, you could either update the query in your code to use a descending order, or modify your indexes to include ascending order like so:
firestore.indexes.json
{
"indexes": [],
"fieldOverrides": [
{
"collectionGroup": "reports",
"fieldPath": "generateDate",
"ttl": false,
"indexes": [
{
"order": "ASCENDING",
"queryScope": "COLLECTION"
},
{
"order": "DESCENDING",
"queryScope": "COLLECTION"
},
{
"arrayConfig": "CONTAINS",
"queryScope": "COLLECTION"
},
{
"order": "DESCENDING",
"queryScope": "COLLECTION_GROUP"
},
{
"order": "ASCENDING",
"queryScope": "COLLECTION_GROUP"
}
]
}
]
}
Also you mentioned that hosting deploys break the exemption and scheduled function. Could you elaborate on that? When deploying to hosting are you using firebase deploy --only hosting
?
from firebase-tools.
Hey @skillitzimberg. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 3 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
from firebase-tools.
Since there haven't been any recent updates here, I am going to close this issue.
@skillitzimberg if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.
from firebase-tools.
Related Issues (20)
- Firebase rules request.resource.contentType undefined. HOT 3
- Export to dotenv fails if config is specified with empty characters in firebase functions. HOT 1
- (Functions)The redeploy option is undefined, but an error message is displayed asking to use the redeploy option. HOT 3
- Incorrect path resolve when other VS Code extensions run firebase related command HOT 2
- punycode deprecation HOT 6
- App hosting fails to build pnpm workspace projects HOT 3
- Unable to scroll in Firebase Google Auth Page HOT 1
- issues HOT 1
- `--force` does not apply to `firebase deploy --only storage`, so programmatically provision are not possible HOT 2
- [HOSTING] Deployment using firebase-tools 13.14.2 still broken on macos HOT 8
- Handle PowerShell comma behavior for parsing command arguments HOT 4
- firebase emulators:start not working HOT 1
- IOS simulator take very long to load after using firebase packages HOT 2
- Firebase functions failing to deploy with EXPIRED error HOT 6
- Encounted a bug when performing flutterfire configure (with using curl -sL https://firebase.tools for CLI installation) HOT 6
- Unable to ignore anything when using nextjs firebase deploy (webframeworks) HOT 2
- I'm not sure where to file this, but not having environments as a first class feature in firebase is wild HOT 3
- tt HOT 1
- da
- Emulator in datastore mode doesn't return `indexUpdates` for commit requests HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from firebase-tools.