Search code examples
firebasegoogle-cloud-functionsfirebase-cli

firebase functions:shell does not emulate state of memory between invocations


I am testing my Cloud Functions with firebase functions:shell and realized that it does not seem to emulate the state of memory between invocations.

let flag = false;
exports.test = functions.https.onCall(async (data, context) => {
  console.log(flag); // this is still false on second call :-(
  flag = true;
  return true;
});

I know that functions should be stateless but as the doc says “Cloud Functions often recycles the execution environment of a previous invocation.” and this works in production. Anyone know if there is a way to test this locally ?


Solution

  • There is currently no way to do this. The issue is being discussed on GitHub. You can follow the issue here.