We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7e96ac2 commit 6170d4cCopy full SHA for 6170d4c
packages/plugin-node/src/services/image.ts
@@ -343,13 +343,16 @@ export class ImageDescriptionService
343
os.tmpdir(),
344
`tmp_img_${Date.now()}.${format}`
345
);
346
- await sharp(data).toFormat(format).toFile(tempFilePath);
347
- const { imageData, mimeType } = await this.fetchImage(tempFilePath);
348
- fs.unlinkSync(tempFilePath); // Clean up temp file
349
- return {
350
- imageData,
351
- mimeType,
352
- };
+ try {
+ await sharp(data).toFormat(format).toFile(tempFilePath);
+ const { imageData, mimeType } = await this.fetchImage(tempFilePath);
+ return {
+ imageData,
+ mimeType,
+ };
353
+ } finally {
354
+ fs.unlinkSync(tempFilePath); // Clean up temp file
355
+ }
356
}
357
358
private async fetchImage(
0 commit comments