Skip to content
Snippets Groups Projects
Unverified Commit 724ba3a7 authored by Kevin Aleman's avatar Kevin Aleman Committed by GitHub
Browse files

fix(pdf-transcript): Don't error out when trying to process an image bigger...

fix(pdf-transcript): Don't error out when trying to process an image bigger than NATS max payload (#32318)
parent e0ba4e66
No related branches found
No related tags found
No related merge requests found
---
'@rocket.chat/omnichannel-services': patch
'@rocket.chat/core-services': patch
'@rocket.chat/meteor': patch
---
Fixed error handling for files bigger than NATS max allowed payload. This should prevent PDFs from erroring out when generating from rooms that contain heavy images.
...@@ -232,8 +232,21 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT ...@@ -232,8 +232,21 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT
continue; continue;
} }
const fileBuffer = await uploadService.getFileBuffer({ file: uploadedFile }); try {
files.push({ name: file.name, buffer: fileBuffer, extension: uploadedFile.extension }); const fileBuffer = await uploadService.getFileBuffer({ file: uploadedFile });
files.push({ name: file.name, buffer: fileBuffer, extension: uploadedFile.extension });
} catch (e: unknown) {
this.log.error(`Failed to get file ${file._id}`, e);
// Push empty buffer so parser processes this as "unsupported file"
files.push({ name: file.name, buffer: null });
// TODO: this is a NATS error message, even when we shouldn't tie it, since it's the only way we have right now we'll live with it for a while
if ((e as Error).message === 'MAX_PAYLOAD_EXCEEDED') {
this.log.error(
`File is too big to be processed by NATS. See NATS config for allowing bigger messages to be sent between services`,
);
}
}
} }
// When you send a file message, the things you type in the modal are not "msg", they're in "description" of the attachment // When you send a file message, the things you type in the modal are not "msg", they're in "description" of the attachment
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment