Skip to content

Commit

Permalink
fix(pdf-transcript): Don't error out when trying to process an image …
Browse files Browse the repository at this point in the history
…bigger than NATS max payload (#32318)
  • Loading branch information
KevLehman committed May 9, 2024
1 parent e0ba4e6 commit 724ba3a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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"
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
Expand Down

0 comments on commit 724ba3a

Please sign in to comment.