Skip to content

fix(http): Add missing timeout and transferCache options to HttpClient #62586

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

Closed
wants to merge 1 commit into from

Conversation

wartab
Copy link
Contributor

@wartab wartab commented Jul 11, 2025

The timeout option is implemented in the different HTTP backends, but the option is not actually passed to the backends. transferCache is also missing in one signature. This commit adds both options to HttpClient

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.dev application / infrastructure changes
  • Other... Please describe:

Issue Number: N/A

Other information

I noticed while doing this that the transferCache option is not always passed. I am not sure why, but in DELETE and PUT requests it's absent, while for GET and POST requests, it is there.

While I understand why it's there for GET, I question why it's absent in PUT if POST has the option. I believe it should be added everywhere for consistency. I can change this PR to do that if needed.

@pullapprove pullapprove bot requested a review from thePunderWoman July 11, 2025 07:53
@angular-robot angular-robot bot added the area: common/http Issues related to HTTP and HTTP Client label Jul 11, 2025
@ngbot ngbot bot added this to the Backlog milestone Jul 11, 2025
The `timeout` option is implemented in the different HTTP backends, but the option is not actually passed to the backends. `transferCache` is also missing in one signature. This commit adds both options to `HttpClient`.

Fixes angular#62581
@wartab wartab force-pushed the timeout-transfer-cache branch from 3644234 to 679822e Compare July 11, 2025 08:42
@JeanMeche
Copy link
Member

By looking at the PR I don't see any changes around transferCache, can you amend the commit message. Thank you.

@wartab
Copy link
Contributor Author

wartab commented Jul 11, 2025

I pointed out where it's added in a review.

Also, I had also mentioned transferCache in general in my PR comment. Iit's absent for PUT, but is present for POST. It does seem inconsistent to me, but I might be overlooking something. Was wondering if I should update the commit to add it everywhere.

@JeanMeche
Copy link
Member

transferCache requires a flag to be enable for POST requests. (see https://angular.dev/api/common/http/HttpTransferCacheOptions)

The reasoning behind that is that POST are something used to pull data on the other hand PUT is (almost) never used to pull data. We still wanted developer to be able to cache some POST request that pull data.

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Jul 11, 2025
Copy link
Contributor

@thePunderWoman thePunderWoman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa whoa whoa...timeout!

Sorry, couldn't resist. LGTM!

reviewed-for: fw-general, public-api

@pullapprove pullapprove bot requested review from atscott, crisbeto and mmalerba July 11, 2025 16:00
Copy link
Member

@JeanMeche JeanMeche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@JeanMeche JeanMeche added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 14, 2025
@thePunderWoman thePunderWoman added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Jul 14, 2025
@AndrewKushnir
Copy link
Contributor

This PR was merged into the repository by commit 1408baf.

The changes were merged into the following branches: main

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: merge The PR is ready for merge by the caretaker area: common/http Issues related to HTTP and HTTP Client target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HttpClient in 20.1 throws TS2769 when using documented 'timeout' option
5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy