-
Notifications
You must be signed in to change notification settings - Fork 26.3k
feat(http): Use the Fetch backend by default #58212
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
base: main
Are you sure you want to change the base?
Conversation
2a9e50c
to
84b663b
Compare
84b663b
to
b86dc15
Compare
*/ | ||
export function withFetch(): HttpFeature<HttpFeatureKind.Fetch> { | ||
return makeHttpFeature(HttpFeatureKind.Fetch, [ | ||
FetchBackend, | ||
{provide: HttpBackend, useExisting: FetchBackend}, | ||
]); | ||
} | ||
|
||
/** | ||
* Configures the current `HttpClient` instance to make requests using the Xhr API. |
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 think it would be meaningful to extend this a bit with information on what this offers, especially its support for upload progress events.
Thinking about it more, do we already document this limitation of fetch
for the 'progress'
response mode? We should probably make it clear there as well that withXhr
is needed to make it work. Does the fetch backend report an error somehow if progress is requested? Is this actually only about upload progress, or also download progress?
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.
Chrome is the only browser that supports a stream as a body (since M105), every browser support streaming the response (hence the support for download progress report).
The FetchBackend doesn't throw any error, it won't just report any progress on uploads. Currently the API only has a single reportProgress
property for both update & download progress report, I don't think we should log any warning.
I've updated the doc for the reportProgress
property to hint a the new limitation with the default implementation.
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.
For this use case, it's unfortunate that reportProgress
is used for both upload and download, which is why I understand that you don't want a warning. However, given it doesn't seem to be possible to use duplex: "half"
with Angular's fetch-backend yet (correct me if I'm wrong), I think a warning would still be good if you set reportProgress
to true
in dev mode, regardless - at least for now.
Not sure what the ratio is of devs using it to report uploads vs. downloads, but from my anecdotal experience, it's usually for uploads.
Introduced back in v15 by angular#47502, its usage with fix with angular#55652 for the `FetchBackend` which will become the default `HttpBackend` with angular#58212
c5180f5
to
c5aebda
Compare
63b41e8
to
754e771
Compare
β¦mentation This commit replaces the `XhrHttpBackend` with the `FetchBackend` as the default implementation of the `HttpBackend`. This introduces a breaking change a the `FetchBackend` does not support the report progress for uploads. The previous behavior (`HttpXhrBackend`) can be restored by setting `withXhr()` in the `provideHttpClient()` provider function. DEPRECATED: `withFetch` is now deprecated, it can be safely removed. BREAKING CHANGE: Use the `HttpXhrBackend` with `provideHttpClient(withXhr)` if you want to keep supporting upload progress reports.
β¦sing the `HttpXhrBackend` implementation. Exisiting applications will be migrated to keep using the XHR backend to prevent any breaking changes. `withXhr()` is to the `provideHttpClient` provider function.
56dc6cf
to
849e801
Compare
β¦` implementation
849e801
to
e07973a
Compare
This PR has some synergy with the recently merged |
Hi, We decided to not change the default HttpBackend for v20 but intend to revisit that for v21. |
Alright, cool. Thanks for letting me know π |
This commit replaces the
HttpXhrBackend
with theFetchBackend
as the default implementation of theHttpBackend
.This introduces a breaking change a the
FetchBackend
does not support the report progress for uploads.The previous behavior (
HttpXhrBackend
) can be enabled by settingwithXhr()
in theprovideHttpClient()
provider function.This PR includes a migration schematics to keep the behavior of existing apps as is.
DEPRECATION:
withFetch
is now deprecated, it can be safely removed.BREAKING CHANGE: Use the
HttpXhrBackend
withprovideHttpClient(withXhr())
if you want to keep supporting upload progress reports.