Closed LijieZhang1998 closed 9 months ago
This is working as intended, and the same way as AWS Lambda.
I'd suggest that you run your initialisation once then keep a variable to prevent it running again, if that's your desired behaviour. That or, run the initialisation in a closure in the file, not in the HTTP handler.
Alex
yes, I think containerized FaaS solutions are all work in this way. Thank you for your confirmation.
My actions before raising this issue
Why do you need this?
I want to check if this platform support stateless function execution.
Current Behaviour
I tested a JS function to call gcp firebase SDK to save data. I found out that each execution of the JS function impacts each other. The "initializeApp" method will throw a "duplicated app" exception when invoking the function after the first time of invocation. Here is the code piece in my
handler.js
file.I think the root cause is that JavaScript allows global variables and
initializeApp
initialize an app variable and won't allow to be initialized again in one Nodejs runtime process. Do you know what I can do to work around this? Function execution become not stateless in this case.Any help is appreciated!