diff --git a/src/Utils/messages.ts b/src/Utils/messages.ts index ae2312296a5..3e802159aa9 100644 --- a/src/Utils/messages.ts +++ b/src/Utils/messages.ts @@ -225,8 +225,13 @@ export const prepareWAMessageMedia = async( encWriteStream.destroy() // remove tmp files if(didSaveToTmpPath && bodyPath) { - await fs.unlink(bodyPath) - logger?.debug('removed tmp files') + try { + await fs.access(bodyPath) + await fs.unlink(bodyPath) + logger?.debug('removed tmp file') + } catch(error) { + logger?.warn('failed to remove tmp file') + } } } )