I have the following async function in Typescript, and it seems that await doesn't block and yield the required result as I expect.
async function getCroppedImgContent(origImgBuffer: Buffer) {
console.log("Inside setCroppedImgContent");
let croppedBuffer = await sharp(origImgBuffer)
.resize(4000, 4000)
.max()
.toBuffer();
console.log("After crop");
return croppedBuffer;
}
"After crop" is not print immediately after "Inside setCroppedImgContent", but a lot later. Looks like await is not working.
sharp().resize().max().toBuffer()return a promise becauseawaitis only really useful when you are awaiting a promise.