Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pdf-transcript): Don't error out when trying to process an image bigger than NATS max payload #32318

Merged
merged 8 commits into from
May 9, 2024
7 changes: 7 additions & 0 deletions .changeset/silly-clocks-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@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.
17 changes: 15 additions & 2 deletions ee/packages/omnichannel-services/src/OmnichannelTranscript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,21 @@ export class OmnichannelTranscript extends ServiceClass implements IOmnichannelT
continue;
}

const fileBuffer = await uploadService.getFileBuffer({ file: uploadedFile });
files.push({ name: file.name, buffer: fileBuffer, extension: uploadedFile.extension });
try {
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"
KevLehman marked this conversation as resolved.
Show resolved Hide resolved
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') {
KevLehman marked this conversation as resolved.
Show resolved Hide resolved
this.log.error(
`File is too big to be processed by NATS. See NATS config for allowing bigger messages to be sent between services`,
);
}
KevLehman marked this conversation as resolved.
Show resolved Hide resolved
}
}

// When you send a file message, the things you type in the modal are not "msg", they're in "description" of the attachment
Expand Down
Loading