Skip to content

feat: wire lifecycle hooks into createFetchHttpClient (Closes #409) - #458

Merged
David-patrick-chuks-02 merged 10 commits into
Lilly-Protocol:mainfrom
Zhiyilang074811:fix-lifecycle-hooks-409
Sep 6, 2026
Merged

feat: wire lifecycle hooks into createFetchHttpClient (Closes #409)#458
David-patrick-chuks-02 merged 10 commits into
Lilly-Protocol:mainfrom
Zhiyilang074811:fix-lifecycle-hooks-409

Conversation

@Zhiyilang074811

Copy link
Copy Markdown
Contributor

Summary

Wires the existing \RequestLifecycleHooks\ interface and \composeHooks\ utility into \createFetchHttpClient, so that \�eforeRequest, \�fterResponse, \onRetry, and \onError\ hooks are actually invoked during real HTTP requests.

Changes

  • src/http/fetch-http-client.ts: Added optional \hooks\ parameter to \createFetchHttpClient; invokes \�eforeRequest\ before each request, \�fterResponse\ on 2xx success, \onRetry\ before each retry delay, and \onError\ on all terminal error paths (4xx/5xx, auth failures, timeouts, transport errors)
  • tests/lifecycle-hooks-integration.test.ts: Added 4 integration tests covering:
    • \�eforeRequest\ → \�fterResponse\ order on 200
    • \onRetry\ on 429-then-success flow
    • \onError\ on terminal 4xx failure
    • Throwing hooks don't break the request flow

Acceptance Criteria

  • Integration test observes \�eforeRequest\ then \�fterResponse\ for a 200 response
  • Same setup observes \onRetry\ on 429-then-success and \onError\ on terminal failure
  • A throwing hook does not reject the underlying request

Closes #409

@Zhiyilang074811

Copy link
Copy Markdown
Contributor Author

Hi! Friendly ping — this PR has been open for a couple of days with all checks passing. Ready for review when you have time. Thanks! 🙏

@Zhiyilang074811

Copy link
Copy Markdown
Contributor Author

Hi! Friendly ping — bounty PR (#409) open for ~2 days, all checks passing. Ready for review. Thanks! 🙏

@David-patrick-chuks-02
David-patrick-chuks-02 merged commit fd7215f into Lilly-Protocol:main Sep 6, 2026
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.

[Bounty: $50] Invoke request lifecycle hooks (beforeRequest/afterResponse/onError/onRetry) in createFetchHttpClient

3 participants