diff --git a/src/Utils/messages-media.ts b/src/Utils/messages-media.ts index 145e34d..1e8bac2 100644 --- a/src/Utils/messages-media.ts +++ b/src/Utils/messages-media.ts @@ -371,13 +371,18 @@ export const encryptedStream = async( didSaveToTmpPath } } catch(error) { - encWriteStream.destroy(error) - writeStream?.destroy(error) - aes.destroy(error) - hmac.destroy(error) - sha256Plain.destroy(error) - sha256Enc.destroy(error) - stream.destroy(error) + try { + // destroy all streams with error + encWriteStream.destroy(error) + writeStream?.destroy(error) + aes.destroy(error) + hmac.destroy(error) + sha256Plain.destroy(error) + sha256Enc.destroy(error) + stream.destroy(error) + } catch{ + // swallow error + } if(didSaveToTmpPath) { try {