adam.baker
adam.baker

Reputation: 1485

Cloud Function fails with message "Error: function crashed out of request scope"

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?" );
});

Upvotes: 0

Views: 30

Answers (1)

adam.baker
adam.baker

Reputation: 1485

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);
});

Upvotes: 1

Related Questions