0

I cannot get the simplest Firebase Cloud Function to execute properly. The code below does not produce any console logging, except for the error: Error: function crashed out of request scope and Function invocation was interrupted.

exports.testFunction = functions.firestore.document('trigger/dummy2').onUpdate(async (change : any, context : any) => { console.log( "How can this fail?" ); }); 

1 Answer 1

1

It was not obvious from the documentation (to me, at least), but async functions are required to return a Promise. If that is an irrelevant requirement, you can return a resolved promise.

exports.testFunction = functions.firestore.document('trigger/dummy2').onUpdate(async (change : any, context : any) => { console.log( "How can this fail?" ); return Promise.resolve(100); }); 
Sign up to request clarification or add additional context in comments.

2 Comments

I would suggest you watch the 3 videos about "JavaScript Promises" from the Firebase video series: firebase.google.com/docs/functions/video-series
Yes, in this case that would have saved me time. FWIW, a simple MWE-type example is often more helpful than a video—though the videos are charming. :-)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.