Skip to content

Commit

Permalink
Merge pull request #616 from eco-stake/fix-connect-error
Browse files Browse the repository at this point in the history
Handle no opts for connect
  • Loading branch information
tombeynon committed Sep 30, 2022
2 parents 0f2ae23 + 12b8d1d commit b16295b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/utils/Network.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ class Network {
this.txTimeout = this.data.txTimeout || 60_000
}

async connect({ timeout }) {
async connect(opts) {
try {
this.queryClient = await QueryClient(this.chain.chainId, this.restUrl, { connectTimeout: timeout })
this.queryClient = await QueryClient(this.chain.chainId, this.restUrl, { connectTimeout: opts?.timeout })
this.restUrl = this.queryClient.restUrl
this.connected = this.queryClient.connected && (!this.usingDirectory || this.connectedDirectory())
} catch (error) {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/QueryClient.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const QueryClient = async (chainId, restUrls, opts) => {
return pages;
};

async function findAvailableUrl(urls, type, { timeout }) {
async function findAvailableUrl(urls, type, opts) {
if(!urls) return

if (!Array.isArray(urls)) {
Expand All @@ -223,6 +223,7 @@ const QueryClient = async (chainId, restUrls, opts) => {
}
}
const path = type === "rest" ? "/blocks/latest" : "/block";
const { timeout } = opts || {}
return Promise.any(urls.map(async (url) => {
url = url.replace(/\/$/, '')
try {
Expand Down

0 comments on commit b16295b

Please sign in to comment.