Skip to content

Commit

Permalink
fix: merge fetchOptions from HttpRpcClient options with request-speci…
Browse files Browse the repository at this point in the history
…fic options (#2193)

* fix: merge fetchOptions from HttpRpcClient options with request-specific options

* Create many-eagles-hang.md

---------

Co-authored-by: jxom <jakemoxey@gmail.com>
  • Loading branch information
mlshv and jxom committed Apr 28, 2024
1 parent 355ea08 commit 5fe7494
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-eagles-hang.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"viem": patch
---

Fixed `fetchOptions` declaration on HTTP RPC.
9 changes: 7 additions & 2 deletions src/utils/rpc/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,21 @@ export function getHttpRpcClient(
async request(params) {
const {
body,
fetchOptions = {},
onRequest = options.onRequest,
onResponse = options.onResponse,
timeout = options.timeout ?? 10_000,
} = params

const fetchOptions = {
...(options.fetchOptions ?? {}),
...(params.fetchOptions ?? {}),
}

const {
headers,
method,
signal: signal_,
} = { ...options.fetchOptions, ...fetchOptions }
} = fetchOptions

try {
const response = await withTimeout(
Expand Down

0 comments on commit 5fe7494

Please sign in to comment.