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

pull/32305/head
Kevin Aleman 2 years ago committed by GitHub
parent e0ba4e6686
commit 724ba3a729
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      .changeset/silly-clocks-return.md
  2. 17
      ee/packages/omnichannel-services/src/OmnichannelTranscript.ts

@ -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.

@ -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"
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

Loading…
Cancel
Save