-
-
Notifications
You must be signed in to change notification settings - Fork 596
perf: Avoid CORS preflight request by removing upload listener when not used #1610
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
Conversation
I will reformat the title to use the proper commit message syntax. |
Thanks for opening this pull request!
|
Thanks for this PR, even with a test case, very nice. Let's for the CI to pass and maybe another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Codecov ReportBase: 99.89% // Head: 99.89% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## alpha #1610 +/- ##
=======================================
Coverage 99.89% 99.89%
=======================================
Files 61 61
Lines 5973 5973
Branches 1367 1367
=======================================
Hits 5967 5967
Misses 6 6
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
# [4.0.0-alpha.3](4.0.0-alpha.2...4.0.0-alpha.3) (2022-11-18) ### Performance Improvements * Avoid CORS preflight request by removing upload listener when not used ([#1610](#1610)) ([6125419](6125419))
🎉 This change has been released in version 4.0.0-alpha.3 |
# [4.0.0-alpha.3](parse-community/Parse-SDK-JS@4.0.0-alpha.2...4.0.0-alpha.3) (2022-11-18) ### Performance Improvements * Avoid CORS preflight request by removing upload listener when not used ([parse-community#1610](parse-community#1610)) ([6125419](parse-community@6125419))
# [4.0.0-beta.1](3.5.1...4.0.0-beta.1) (2023-01-23) ### Bug Fixes * `Parse.Query.subscribe()` does not return a rejected promise on error in Cloud Code Triggers `beforeConnect` or `beforeSubscribe` ([#1490](#1490)) ([96d7174](96d7174)) * Remove support for Node <14 ([#1603](#1603)) ([bc04b4b](bc04b4b)) ### Features * Add Node 16 and 18 support ([#1598](#1598)) ([2c79a31](2c79a31)) * Add node 19 support ([8ed0fab](8ed0fab)) * Add Node 19 support ([#1643](#1643)) ([dfb5196](dfb5196)) ### Performance Improvements * Avoid CORS preflight request by removing upload listener when not used ([#1610](#1610)) ([6125419](6125419)) ### BREAKING CHANGES * Calling `Parse.Query.subscribe()` will now return a rejected promise if an error is thrown in Cloud Code Triggers `beforeConnect` or `beforeSubscribe`; in previous releases a resolved promise was returned, even if subscribing failed and it was necessary to create an `error.on` listener to handle these errors (#1490) ([96d7174](96d7174)) * This release removes support for Node versions <14 ([bc04b4b](bc04b4b))
🎉 This change has been released in version 4.0.0-beta.1 |
# [4.0.0](3.5.1...4.0.0) (2023-01-23) ### Bug Fixes * `Parse.Query.subscribe()` does not return a rejected promise on error in Cloud Code Triggers `beforeConnect` or `beforeSubscribe` ([#1490](#1490)) ([96d7174](96d7174)) * Remove support for Node <14 ([#1603](#1603)) ([bc04b4b](bc04b4b)) ### Features * Add Node 16 and 18 support ([#1598](#1598)) ([2c79a31](2c79a31)) * Add node 19 support ([8ed0fab](8ed0fab)) * Add Node 19 support ([#1643](#1643)) ([dfb5196](dfb5196)) ### Performance Improvements * Avoid CORS preflight request by removing upload listener when not used ([#1610](#1610)) ([6125419](6125419)) ### BREAKING CHANGES * Calling `Parse.Query.subscribe()` will now return a rejected promise if an error is thrown in Cloud Code Triggers `beforeConnect` or `beforeSubscribe`; in previous releases a resolved promise was returned, even if subscribing failed and it was necessary to create an `error.on` listener to handle these errors (#1490) ([96d7174](96d7174)) * This release removes support for Node versions <14 ([bc04b4b](bc04b4b))
🎉 This change has been released in version 4.0.0 |
New Pull Request Checklist
Issue Description
Related issue: #1609
Closes #1609
Starting with v2.13.0, most Parse JS SDK operations began triggering the need for a preflight request. This is due to the addition of a progress listener on upload for all XHR requests with
RESTController
: #1133 . This listener triggers the need for a preflight request: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/upload#sect1While this upload progress listener is useful in cases where a progress callback is being used, it should not be set when no progress callback is provided to avoid the performance issue.
Approach
Only set the progress listeners on the XHR when a progress callback is provided.
TODOs before merging