-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix inconsistent response when preloading OPTIONS type requests #38051
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
|
Size Change: +5.75 kB (+1%) Total Size: 1.14 MB
ℹ️ View Unchanged
|
|
See also #28862 |
@chrisvanpatten |
|
Just noting that it's related. |
|
Let's note the breaking change in |
getdave
left a comment
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.
I just did a quick confidence check in @wordpress/core-data and the only OPTIONS request is in canUser resolver when requesting a singular resource with an ID. That request already uses parse: false so this should be safe.
Have yet to manually test.
I've completely forgotten that I need to update the changelog. Thank you. |
Thank you for the review, @getdave. |
getdave
left a comment
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.
I tested as per the instructions and it worked as expected.
I also searched the codebase for parse: false instances and almost all of them do not use OPTIONS requests. I noted already that canUser does use OPTIONS but that seems ok.
I would appreciate a confidence check from @adamziel or someone else experienced with the data layer.
| }; | ||
| } | ||
|
|
||
| /** |
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.
Add a comment here explaining the purpose of the function. Mainly the "why".
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.
Thanks.
Fixed in a7b1221
kevin940726
left a comment
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.
LGTM 👍
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.
It looks good. Note that it's a breaking change – you can no longer preload the status or headers of the OPTIONS request. I think that's fine. It wasn't possible for the GET requests anyway, and as others noticed it wasn't even used. 🚢
getdave
left a comment
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.
LGTM
Description
Preloading middleware doesn't return consistent responses for
OPTIONStype requests if theparseoption is set tofalse.This PR aims to fix the preloading middleware so that it returns
window.Responseobject if theparseoption is set to false.Although this is a breaking change I haven't noticed any issues with preloading.
Fixes #37966
How has this been tested?
Expected result (after the fix):
You should see
Responseobject in the console (please see the screenshot), because we chose not to parse the response (parse: false).Actual result (before this fix):
You will see
From middlewaretext in the console as if the response was parsed.Screenshots
Types of changes
Bug fix
Checklist:
*.native.jsfiles for terms that need renaming or removal).