-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
API Fetch: Make preloaded OPTIONS requests use parse
setting
#28862
Conversation
Another inconsistency that would be nice to resolve is that unlike |
If we're comfortable breaking backcompat here and are overall happy with the approach, I'd be totally happy to implement that @TimothyBJacobs |
Size Change: +6 B (0%) Total Size: 1.46 MB
ℹ️ View Unchanged
|
I have a version implemented locally that changes the response to use a true |
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 seems to be a good idea to align API for different methods of requests. Should we also include a note in the changelog of the package so people were aware of the new option added? Is there any higher level documentation that needs to be updated as well?
@@ -2,6 +2,10 @@ | |||
|
|||
## Unreleased | |||
|
|||
### Breaking changes | |||
|
|||
- `OPTIONS` requests which are handled by the preloading middleware are no longer resolved as unparsed responses unless you explicitly set `parse: false`, for consistency with other request methods. If you expect an unparsed response, add `{ parse: false }` to your request options to preserve the previous behavior. |
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.
Does it impact any existing REST API calls in Gutenberg?
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 does not impact any existing calls in the Gutenberg codebase — I think the reason this wasn't noticed previously is that all the core requests already explicitly set { parse: false }
… it just wasn't actually doing anything!
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 can confirm it now that you mentioned it :)
parse
settingparse
setting
@gziolo Thanks for merging — the performance tests were dragging on and I lost track of my open tab 😁 |
Yes, it takes over 40 minutes, there is even an issue that prompts some action 😄 |
Description
When preloading requests via the preloading middleware, the middleware changes the shape of the returned response for
GET
requests based on the value of theparse
flag. However, it does not do the same forOPTIONS
requests, which are always returned in their unparsed form (with body and header properties).This behavior appears to originate with the work around verifying media upload capabilities in #4155.
As far as I can tell, Gutenberg/Core only makes OPTIONS requests with
parse: false
as the requests are looking for header data, so this change should not impact core code. (It already receives the response shape it expects to get, and will continue to do so.)How has this been tested?
Added unit tests.
Types of changes
This is technically a breaking change, if users implemented preloading expecting the incorrect response shape. I know there are larger discussions happening around issues with preloading, so it may make sense to punt this until those conversations are resolved.
Checklist: