Skip to content

Commit

Permalink
Merge branch 'main' into fix-crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
icezohu authored May 12, 2024
2 parents 32869ce + f09eecb commit 1785448
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
Empty file added .yarn/versions/8f3f4961.yml
Empty file.
2 changes: 1 addition & 1 deletion packages/network-support/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@
"browser": {
"node-fetch": false
},
"stableVersion": "1.1.0"
"stableVersion": "1.2.2"
}
21 changes: 13 additions & 8 deletions packages/network-support/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export class FetchError extends Error {
export function createFetch(
orderManager: OrderManager,
maxRetries = 5,
logger?: Logger
logger?: Logger,
overrideFetch?: typeof fetch
): (init: RequestInit) => Promise<Response> {
let retries = 0;
let triedFallback = false;
Expand Down Expand Up @@ -64,14 +65,18 @@ export function createFetch(
}
const { url, headers, type, runner, channelId } = requestParams;
try {
const _res = await customFetch(url, {
headers: {
...(init.headers || {}),
...headers,
const _res = await customFetch(
url,
{
headers: {
...(init.headers || {}),
...headers,
},
method: 'post',
body: init.body,
},
method: 'post',
body: init.body,
});
overrideFetch
);
let res: object;
if (type === OrderType.flexPlan) {
[res] = orderManager.extractChannelState(
Expand Down
6 changes: 4 additions & 2 deletions packages/network-support/src/utils/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export const timeoutController = () => {

export const customFetch = (
input: URL | RequestInfo,
init?: RequestInit | undefined
init?: RequestInit | undefined,
overrideFetch?: typeof fetch
): Promise<Response> => {
return fetch(input, {
overrideFetch = overrideFetch ?? fetch;
return overrideFetch(input, {
signal: timeoutController().signal,
...init,
});
Expand Down

0 comments on commit 1785448

Please sign in to comment.