Function execution took ****ms, finished with status: 'connection error' or ECONNRESET usually happens when a function doesn’t know whether a promise resolved or not.
Every promise must be returned, as mentioned in the docs here. There is also a blog post (with helpful video!) about this.
A couple of examples of unreturned promises:
exports.someFunc = functions.database.ref('/some/path').onCreate(event => { let db = admin.database(); // UNRETURNED PROMISE db.ref('/some/path').remove(); return db.ref('/some/other/path').set(event.data.val()); });
exports.makeUppercase = functions.database.ref('/hello/{pushId}').onWrite(event => { return event.data.ref.set('world').then(snap => { // UNRETURNED PROMISE admin.database().ref('lastwrite').set(admin.database.ServerValue.TIMESTAMP); }); });
exports.makeUppercase = functions.database.ref('/hello/{pushId}').onWrite(event => { // UNRETURNED PROMISE event.data.ref.set('world').then(snap => { return admin.database().ref('lastwrite').set(admin.database.ServerValue.TIMESTAMP); }); });
To help catch this mistake before deploying code, check out this eslint rule.
For an in-depth look at promises, here are some helpful resources: