FlowCrypt / flowcrypt-browser

FlowCrypt Browser extension for Chrome and Firefox
https://flowcrypt.com
Other
372 stars 46 forks source link

"Rich text (PGP/MIME) - experimental" produces larger messages, causing Gmail API 413 #4041

Open limonte opened 3 years ago

limonte commented 3 years ago

Here's what I'm getting when I try to send encrypted message with 4 large CSV files:

CleanShot 2021-10-05 at 10 25 12@2x

In Chrome I am able to send the exact same message.

All CSV files are the copy of this file: 50000.Sales.Records.csv

limonte commented 3 years ago

Quick investigation, Gmail API returns 413:

Request Entity Too Large: 413 when POST-ing https://www.googleapis.com/upload/gmail/v1/users/me/messages/send?uploadType=multipart string: not-a-json -> Media is too large. Limit: 36700160"

limonte commented 3 years ago

Interestingly, the size of the encrypted message is different in Chrome and Firefox:

Almost twice bigger in Firefox for the same message from the issue description.

tomholub commented 2 years ago

This is very interesting

tomholub commented 2 years ago

Assigning Ivan to sometime later investigate why would Firefox produce larger messages.

IvanPizhenko commented 2 years ago

@limonte @tomholub I could not reproduce this. I have latest Firefox 94.0 on Ubuntu 20.04 LTS. I've sent email from "Flowcrypt Compatibility" to myself with 4 copies of that attached w/o issue. email ref: https://mail.google.com/mail/u/2/#sent/WhctKKXHDWpPWprJNGpkDqJcgrMMVkBLnnMNSDDfBGMkNtHVwKVzGnxTkwzzkMBPpXGlKqg

IvanPizhenko commented 2 years ago

image

limonte commented 2 years ago

My bad here, sorry for wasting your time @IvanPizhenko

When reporting the issue I didn't notice the enabled "Rich text (PGP/MIME) - experimental":

CleanShot 2021-11-14 at 22 02 16@2x

So, the issue is actually "Rich text (PGP/MIME) - experimental" produces twice bigger request body. After this line https://github.com/FlowCrypt/flowcrypt-browser/blob/master/extension/js/common/api/email-provider/gmail/gmail.ts#L91 console.log(request.body.length) logs:

tomholub commented 2 years ago

Thank you both.

There is indeed some inefficiency in how we encode attachments with PGP/MIME. They are too big. I'm not exactly sure what it is - probably using a base64 somewhere where a binary representation would do, and maybe more than once.

I'm not too keen on trying to fix it until Google fixes this bug in Gmail API: #3157