Skip to content

Commit

Permalink
fix: unhandled https require
Browse files Browse the repository at this point in the history
  • Loading branch information
flagrede committed Sep 5, 2023
1 parent 75cebea commit 9ff7acd
Show file tree
Hide file tree
Showing 4 changed files with 4,205 additions and 4,941 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
"start-auth": "lerna run --scope web-auth start --stream",
"watch": "lerna run watch --stream",
"test-update-snapshot": "lerna run --scope web-marketplace test-update-snapshot --stream",
"bump": "lerna version --conventional-commits"
"bump": "lerna version --conventional-commits",
"postinstall": "patch-package"
},
"devDependencies": {
"@graphql-codegen/cli": "1.21.4",
Expand All @@ -52,7 +53,6 @@
"@storybook/addon-links": "^7.0.26",
"@storybook/react": "^7.0.26",
"@storybook/react-vite": "^7.0.26",
"storybook": "^7.0.26",
"@types/css-mediaquery": "^0.1.1",
"@types/jest": "27.0.3",
"@types/node": "13.1.1",
Expand All @@ -62,8 +62,10 @@
"eslint-plugin-prettier": "^4.0.0",
"husky": "^3.1.0",
"lerna": "^6.4.1",
"patch-package": "^8.0.0",
"prettier": "2.4.1",
"shx": "^0.3.2",
"storybook": "^7.0.26",
"typescript": "^4.4.4"
},
"resolutions": {
Expand Down
44 changes: 44 additions & 0 deletions patches/@ledgerhq+live-network+1.1.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/node_modules/@ledgerhq/live-network/lib-es/network.js b/node_modules/@ledgerhq/live-network/lib-es/network.js
index 41aa14e..f710a9e 100644
--- a/node_modules/@ledgerhq/live-network/lib-es/network.js
+++ b/node_modules/@ledgerhq/live-network/lib-es/network.js
@@ -4,6 +4,7 @@ import { retry } from "@ledgerhq/live-promise";
import { log } from "@ledgerhq/logs";
import axios from "axios";
import invariant from "invariant";
+import { HttpsAgent } from 'agentkeepalive';
export const requestInterceptor = (request) => {
if (!getEnv("ENABLE_NETWORK_LOGS")) {
return request;
@@ -72,8 +73,7 @@ if (!(typeof navigator !== "undefined" && navigator.product === "ReactNative"))
// the keepAlive is necessary when we make a lot of request in in parallel, especially for bitcoin sync. Otherwise, it may raise "connect ETIMEDOUT" error
// refer to https://stackoverflow.com/questions/63064393/getting-axios-error-connect-etimedout-when-making-high-volume-of-calls
// eslint-disable-next-line global-require,@typescript-eslint/no-var-requires
- const https = require("https");
- axios.defaults.httpsAgent = new https.Agent({ keepAlive: true });
+ axios.defaults.httpsAgent = new HttpsAgent({ keepAlive: true });
}
const makeError = (msg, status, url, method) => {
const obj = {
diff --git a/node_modules/@ledgerhq/live-network/src/network.ts b/node_modules/@ledgerhq/live-network/src/network.ts
index de91e00..9fa132f 100644
--- a/node_modules/@ledgerhq/live-network/src/network.ts
+++ b/node_modules/@ledgerhq/live-network/src/network.ts
@@ -5,6 +5,7 @@ import { log } from "@ledgerhq/logs";
import type { AxiosError, AxiosRequestConfig, Method } from "axios";
import axios, { AxiosPromise, AxiosResponse } from "axios";
import invariant from "invariant";
+import { HttpsAgent } from 'agentkeepalive';

type Metadata = { startTime: number };
type ExtendedXHRConfig = AxiosRequestConfig & { metadata?: Metadata };
@@ -104,8 +105,7 @@ if (!(typeof navigator !== "undefined" && navigator.product === "ReactNative"))
// the keepAlive is necessary when we make a lot of request in in parallel, especially for bitcoin sync. Otherwise, it may raise "connect ETIMEDOUT" error
// refer to https://stackoverflow.com/questions/63064393/getting-axios-error-connect-etimedout-when-making-high-volume-of-calls
// eslint-disable-next-line global-require,@typescript-eslint/no-var-requires
- const https = require("https");
- axios.defaults.httpsAgent = new https.Agent({ keepAlive: true });
+ axios.defaults.httpsAgent = new HttpsAgent({ keepAlive: true });
}

const makeError = (msg: string, status: number, url: string | undefined, method: Method | "") => {
1 change: 1 addition & 0 deletions web-marketplace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@types/react-router-dom": "^5.3.3",
"@vitejs/plugin-react": "^4.0.0",
"@walletconnect/utils": "^1.8.0",
"agentkeepalive": "^4.5.0",
"analytics": "^0.8.1",
"analytics-plugin-do-not-track": "^0.1.5",
"auth0-js": "^9.18.0",
Expand Down
Loading

0 comments on commit 9ff7acd

Please sign in to comment.