Open Fawwaz-2009 opened 3 years ago
I've deployed a fix that seems to be working 99% of the time, but as you can see it's a hack 😅
function canvasRegisterFont(fontFilePath: string, { family }: { family: string }, tryNumber = 1): void {
try {
registerFont(fontFilePath, { family });
} catch (error) {
if (tryNumber < 3) {
console.log(error);
console.log(`try number ${tryNumber} for registering the font has failed has failed, trying again....`);
return canvasRegisterFont(fontFilePath, { family }, tryNumber + 1);
}
}
}
@Fawwaz-2009 Have you tried other / durable storage options as suggested in AWS blog post: https://aws.amazon.com/blogs/compute/choosing-between-aws-lambda-data-storage-options-in-web-apps/?
hey @charoitel No I didn't but I doubt it would help. Few days back I wanted to build a demo locally to test another bug and I discovered that the issue of registerFont
is not happening on AWS lambda but even in my local setup (MacOS). What is worse is that the wrapper solution approve ( canvasRegisterFont
) is not reliable on MacOS. While on Lambda the registerFont
may fail twice, on MacOS it fail 10+ (didn't try to go higher).
unfortunately I'm not sure why is it happening or how to debug this.
Also experiencing this.
Issue or Feature
I'm noticing that
registerFont
is not reliable inside AWS Lambda. What I've observed that if I call Lambda function half the time it would work and the other half it would not. I'm using the/tmp
folder to temporally write the font files there soregisterFont
can load them. The error I'm saying isError: Could not parse font file at Object.registerFont
Steps to Reproduce
Here is the piece of code loading the font
Your Environment
npm list canvas
oryarn list canvas
): canvas@2.8.0apologies in advance if the above is not enough to go on, this is really at the edge of my expertises.
Edit: one more point I want to clarify is that I've already checked that if error happens because the preceding write operation has failed and turns out that is not the case. I checked by using
fs.existsSync
and listing the content of the/tmp
folder and in both cases I can say the font file each time, before the call toregisterFont