Fix inconsistent response when preloading OPTIONS type requests#38051
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.
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.
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.
Add a comment here explaining the purpose of the function. Mainly the "why".
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).