Downloading files of about 5Mb results in an "internal server error"
IjzerenHein opened this issue · 3 comments
Version
5.38.1 (but also applies to 5.33.0)
Operating System
Mac OSX
Browser
Google Chrome
What are the steps to reproduce this bug?
Setup a fresh Webiny project:
npx create-webiny-project my-filemanager-test
yarn webiny deploy
- Finish the setup and complete the installation wizard
Upload a file and try to download it
- Go to the Admin app and upload the attached file to the File Manager
- Attempt to download the file
- This results in the lambda returning "internal server error", instead of downloading the file
File that causes the problem
hein_test.mp4
What is the expected behavior?
The file should be downloaded successfully
What do you see instead?
{"message":"Internal Server Error"}
Additional information
The interesting part is that larger files and smaller files do work. However, we have several files in this ~5 Mb file range and they all seem to fail. It looks like it has something to do with the fact that the filemanager lambda switches to a 301 for larger files and serves smaller files directly. But somewhere in the middle it fails.
Possible solution
No response
We did some further experimentation, and it seems that files smaller than 4703427
bytes and files larger than 5095107
always seem to work. But somewhere between that range the file-manager is unable to serve the files and returns internal server error
.
Looking at the implementation, there seems to be a limit or 5000000
which serves as a switch from the serving the file directly or redirecting the file to be served from the bucket:
https://github.com/webiny/webiny-js/blob/next/packages/api-file-manager/src/handlers/download/getS3Object.ts#L17C27-L17C61
From what I can see, it appears that this limit of 5000000
is too large and should probably be decreased to something like 4700000
.
@IjzerenHein Can I give it a try/
@ptdatta yes please, can you reproduce it?