Closed silviacir closed 2 years ago
Multipart requests are streamed in chunks of data. If it can be determined the file size limit is exceeded from the very first chunk received, it errors early to avoid the overhead of setting up a stream for the sole purpose of emitting an error. This is the expected and tested behavior, but it can always be changed if something else makes better sense.
It's been years now since we came up with the current system so I'm too rusty to give a detailed technical justification for the way it currently works without a deep dive, but I have faint memories of questioning this exact behavior several times, looked at doing it another way, but then when I understood the problem better I realised it was good how it was.
Closing because it's working as originally designed, but if people would like to add more feedback or suggest a different design feel free to continue the conversation here.
I am using
"graphql-upload": "^13.0.0"
along with"apollo-server-express": "^3.1.2"
. I've put the following express middlewareWith the following code as part of a mutation's resolver
and noticed the following behaviour when a file exceeded the
maxFileSize
has been put: ifGQL_UPLOAD_MAX_FILE_SIZE < 63000 KB
(approximately) the error is thrown increateReadStream
method and so caught in thecatch
branch. ifGQL_UPLOAD_MAX_FILE_SIZE > 63000 KB
(again, approximately) I need to catch the error in the listener of theerror
event.The message is the same
PayloadTooLargeError: File truncated as it exceeds the 63000 byte size limit.
in both cases.Any idea what could be the mistake?