I have this cloud function:
const initCompress = async () => {
try {
logger.log('This shows before the function terminated');
await mkdirp('../../../xxxxx'); <<<< WHY IS IT NOT WAITING FOR THIS TO COMPLETE?
logger.log('This shows after the function terminated');
return { success: true };
} catch (err) {
...
} finally {
...
}
};
export default initCompress;
It is executed via:
const main = async () => {
exports.compressImage = functions.https.onCall((data, context) => {
initCompress(data, context);
});
}
The console log shows:
functions: Beginning execution of "compressImage"
> {"severity":"INFO","message":"This shows before the function terminated"}
functions: Finished "compressImage" in ~1s
> {"severity":"INFO","message":"This shows after the function terminated"}
I'm probably doing something silly, but what? Do I need to await something somewhere?