graphql-upload: MaxFileSizeUploadError can't be caught and crashes the server
Hi!
I have a problem with a custom middleware and the use of the processRequest function. Here is my custom middleware:
try {
return processRequest(request, options)
.then(body => {
console.log("body is : ", body);
ctx.request.body = body;
return next();
})
.catch(error => {
console.log("Error catched : ", error);
if (error.status && error.expose) response.status(error.status);
return next(error)
});
} catch (error) {
console.log("Error catched bis : ", error);
}
If I try to upload a file bigger than the allowed limit, I get the following error and my app crash.
events.js:137
throw er; // Unhandled 'error' event
^
MaxFileSizeUploadError: File truncated as it exceeds the size limit.
at FileStream.file.stream.once (/Volumes/lake/projects/evibe/api-lovejs/node_modules/apollo-upload-server/lib/middleware.js:35:13)
at Object.onceWrapper (events.js:255:19)
at FileStream.emit (events.js:160:13)
I can’t capture the error. Any idea?
Thanks 😃
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 16 (8 by maintainers)
Commits related to this issue
- Added a (failing) test for when exceeded max file size. Reproduces https://github.com/jaydenseric/apollo-upload-server/issues/45. — committed to jaydenseric/graphql-upload by jaydenseric 6 years ago
- Added a (failing) test for when exceeded max file size. Reproduces https://github.com/jaydenseric/apollo-upload-server/issues/45. — committed to krasivyy3954/react-graphql-upload by krasivyy3954 6 years ago
I have the same problem, in my case file stream throw error and not exist handlers for that error.
Solution in my case: wrap stream in promise
@jaydenseric I use
apollo-server-koa, how can i fix this? waitapollo-server-koause new version ofapollo-upload-server?