Skip to content

feat: add onBackgroundRefreshFailed hook to AbstractUseStaleRequest#30

Merged
jwadhams merged 1 commit into
developmentfrom
feat/MR-7177-background-refresh-failure-hook
Apr 17, 2026
Merged

feat: add onBackgroundRefreshFailed hook to AbstractUseStaleRequest#30
jwadhams merged 1 commit into
developmentfrom
feat/MR-7177-background-refresh-failure-hook

Conversation

@an-adamchuk
Copy link
Copy Markdown

@an-adamchuk an-adamchuk commented Apr 17, 2026

Release Notes

Adds an extensibility hook to AbstractUseStaleRequest so consumers can observe background refresh failures without the library forcing specific behaviour.

Technical Notes

The background refresh closure previously swallowed all \Throwable silently:

} catch (\Throwable) {
    // Nobody cares, this is literally what use-stale is good at
}

The new no-op hook:

} catch (\Throwable $e) {
    $reRequest->onBackgroundRefreshFailed($e);
}

protected function onBackgroundRefreshFailed(\Throwable $e): void {}

Consumers override onBackgroundRefreshFailed() in their subclass or via a trait to add logging or metrics. The library itself stays behaviour-neutral.

Corresponding Tickets

MR-7177

Checklist

  • PR is ready to review
  • Enough tests are added to feel fully confident
  • Product / Stakeholder signoff

Replaces the silent catch block in the background refresh closure with a
no-op hook method. Consumers can override onBackgroundRefreshFailed() to
add logging or metrics without the library forcing a specific behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jwadhams jwadhams merged commit 875f9b2 into development Apr 17, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants