You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Firebase 8.0.1 comes with a testing feature to disable functions triggers in emulator, I tried to use that new feature to clear Firestore data without triggering some triggers to make my tests more reliable, but that not worked, the triggers are called even wrapping custom firestore queries to delete the data manually
Steps to reproduce:
Init a project using firebase init
Set an actual project
Create a bunch of docs on a single collection (I used 'affiliates')
Make sure to use the real project name in initializeTestApp to allow triggers to run
After wrapping the clearFirestore code make the code wait some seconds the allow triggers to run
test('disable triggers test',async()=>{awaitfirebase.withFunctionTriggersDisabled(async()=>{returnawaitfirebase.clearFirestoreData({projectId: APP_ID});});// sleep three seconds to allow triggers to runawaitsleep(3000);constdoc=awaitdb.collection('bar').doc('bar').get();expect(doc.data()).toBeUndefined()},10000);// increase test timeout
@saculbr you're right I was able to reproduce this! I think this is a fairly simple race condition where this happens:
Functions triggers are disabled
Wait for firestore delete operations to finish
Function triggers are enabled
Firestore emulator sends the delete triggers to the Functions emulator a fraction of a second later
I think this theory is correct because adding a sleep works:
awaitfirebase.withFunctionTriggersDisabled(async()=>{awaitfirebase.clearFirestoreData({projectId: 'fir-dumpster'});// This prevents the raceawaitsleep(5000);});
The problem
Firebase 8.0.1 comes with a testing feature to disable functions triggers in emulator, I tried to use that new feature to clear Firestore data without triggering some triggers to make my tests more reliable, but that not worked, the triggers are called even wrapping custom firestore queries to delete the data manually
Steps to reproduce:
Repository with test
https://github.com/saculbr/disableTriggersIssue
Relevant Code:
The text was updated successfully, but these errors were encountered: