jaydenseric / graphql-upload

Middleware and an Upload scalar to add support for GraphQL multipart requests (file uploads via queries and mutations) to various Node.js GraphQL servers.
https://npm.im/graphql-upload
MIT License
1.43k stars 131 forks source link

Improve the `processRequest` function #273

Closed jaydenseric closed 2 years ago

jaydenseric commented 2 years ago

Improved the processRequest function:

jaydenseric commented 2 years ago

@mike-marcacci although this PR is a draft, please review these changes as well the changes in the next branch, particularly the changes to test/abortingMultipartRequest.mjs:

https://github.com/jaydenseric/graphql-upload/commit/b47970970cce60f46bd731abbd8255f5ad8ca8c9#diff-bcc38e6adea970039237a8373729520e8219c640ec7777bc17becf0ec5a6e6b4R1

This PR is only a draft because I would like us to figure out if we need to add extra tests or not, as mentioned at the end of the PR description.

jaydenseric commented 2 years ago

So, in our tests the only time the file stream error listener is called is for the abort tests, and in both cases fileError === exitError:

Screen Shot 2021-11-02 at 2 48 21 pm

There must be some other scenarios when busboy emits an error on the file read stream that we can test. Maybe some sort of bad characters in the file or something?