Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the processRequest function #273

Merged
merged 3 commits into from Nov 29, 2021

Conversation

jaydenseric
Copy link
Owner

@jaydenseric jaydenseric commented Nov 2, 2021

Improved the processRequest function:

  • Fixed ending requests from being handled incorrectly as aborting in edge cases. Closes #272.

    I can't think of a way to reproduce the timing issues described in the above PR in a test. I wasn't even able to reproduce them locally. Considering we've never had reports before about such a thing, I wonder if there is something weird about the environment they were discovered in. Regardless, the new way we're doing it in this PR should solve any timing issues. It's also less listeners and the code is simpler and more obvious, so it's nicer to do it this more modern way anyway.

    Some of these nicer new ways of doing things weren't possible with the Node.js APIs that existed when graphql-upload was worked on over the years; readable.readableEnded was only added in Node.js v12.9.0 (which fits our new Node.js version support that begins at ^12.20.0).

  • Fixed read streams created via the resolved Upload scalar value createReadStream method:

@jaydenseric
Copy link
Owner Author

@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:

b479709#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
Copy link
Owner Author

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?

@jaydenseric jaydenseric marked this pull request as ready for review November 2, 2021 04:33
Copy link
Collaborator

@mike-marcacci mike-marcacci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long delay in reviewing this. I had forgotten about it until you made this comment.

These are excellent changes and fixes, and I have no notes or suggestions here!

@jaydenseric jaydenseric merged commit e9e7ff5 into next Nov 29, 2021
@jaydenseric jaydenseric deleted the jaydenseric/improve-processRequest branch November 29, 2021 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants