Skip to content
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

feat(http): onFetchRequest #2048

Merged
merged 5 commits into from
Mar 31, 2024
Merged

feat(http): onFetchRequest #2048

merged 5 commits into from
Mar 31, 2024

Conversation

tmm
Copy link
Member

@tmm tmm commented Mar 30, 2024

PR-Codex overview

This PR enhances the http transport in viem by adding an onFetchRequest callback.

Detailed summary

  • Added onFetchRequest callback to http transport for handling fetch requests.
  • Modified http function to include onFetchRequest and onFetchResponse options.
  • Updated HttpRpcClientOptions with onRequest and onResponse callbacks.
  • Implemented onFetchRequest and onRequest handling in various test cases.
  • Improved getHttpRpcClient function to utilize onRequest callback for request handling.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Mar 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
viem ❌ Failed (Inspect) Mar 31, 2024 9:28pm

Copy link

changeset-bot bot commented Mar 30, 2024

🦋 Changeset detected

Latest commit: 6dbe040

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@tmm tmm force-pushed the tmm/on-fetch-request branch from b8871cc to b8fe3e4 Compare March 30, 2024 16:52
fetchOptions?: Omit<RequestInit, 'body'> | undefined
// A callback to handle the response.
/** A callback to handle the request. */
onRequest?: ((request: Request) => Promise<void> | void) | undefined
Copy link
Member Author

Choose a reason for hiding this comment

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

Might be more useful to type with input and init instead.

(input: string | Request | URL, init?: RequestInit | undefined) => Promise<void> | void

Copy link
Contributor

github-actions bot commented Mar 30, 2024

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
viem (esm) 66.46 KB (0%) 1.4 s (0%) 4.2 s (+17.17% 🔺) 5.6 s
viem (cjs) 86.31 KB (0%) 1.8 s (0%) 9.7 s (+123.09% 🔺) 11.4 s
viem (minimal surface - tree-shaking) 3.76 KB (0%) 76 ms (0%) 67 ms (-82.71% 🔽) 143 ms
viem/accounts 91.47 KB (0%) 1.9 s (0%) 1.3 s (+74.25% 🔺) 3.2 s
viem/accounts (tree-shaking) 21.09 KB (0%) 422 ms (0%) 791 ms (+8.51% 🔺) 1.3 s
viem/actions 46.67 KB (0%) 934 ms (0%) 1.4 s (+18.83% 🔺) 2.4 s
viem/actions (tree-shaking) 340 B (0%) 10 ms (0%) 54 ms (+117.6% 🔺) 64 ms
viem/chains 30.92 KB (0%) 619 ms (0%) 1.3 s (+1.67% 🔺) 1.9 s
viem/chains (tree-shaking) 367 B (0%) 10 ms (0%) 31 ms (+5.5% 🔺) 41 ms
viem/chains/utils 1.16 KB (0%) 24 ms (0%) 36 ms (-4.33% 🔽) 59 ms
viem/ens 46.67 KB (+0.01% 🔺) 934 ms (+0.01% 🔺) 1.1 s (+28.35% 🔺) 2 s
viem/ens (tree-shaking) 20.69 KB (0%) 414 ms (0%) 566 ms (-53.55% 🔽) 980 ms

Copy link

codecov bot commented Mar 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.65%. Comparing base (d89514a) to head (d74e39a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2048      +/-   ##
==========================================
- Coverage   92.65%   92.65%   -0.01%     
==========================================
  Files         568      568              
  Lines       49472    49479       +7     
  Branches     1900     1899       -1     
==========================================
+ Hits        45840    45845       +5     
- Misses       3589     3591       +2     
  Partials       43       43              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jxom jxom merged commit 85c3695 into main Mar 31, 2024
8 of 20 checks passed
@jxom jxom deleted the tmm/on-fetch-request branch March 31, 2024 21:18
@github-actions github-actions bot mentioned this pull request Mar 31, 2024
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