Kevinrob / guzzle-cache-middleware

A HTTP Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack.
MIT License
409 stars 77 forks source link

Always return stale response if exist on promise rejected callback #169

Closed e-zannelli closed 11 months ago

e-zannelli commented 1 year ago

The code check if the rejection is a TransferException before looking for a stale response, but the next handler can reject with anything (e.g. Ganesha reject with its own exception when the circuit is open) and we loose the stale-on-error that we expect.

The proposition here is to just always return stale response if exist on rejected callback. I could also propose some sort of service to inject to decide if stale response should be looked for if that is more acceptable.

What do you think?

Thanks.

Kevinrob commented 11 months ago

@e-zannelli Thank you for this PR!

Can you write tests for this and rebase from master?