Skip to content

Commit

Permalink
add better error message
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Jan 28, 2025
1 parent a909dfe commit b8891d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions deployables/extension/src/background/rpcTracking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const detectNetworkOfRpcUrl = async (
url,
timeout(
sendMessageToTab(tabId, { type: RpcMessageType.PROBE_CHAIN_ID, url }),
`Could not probe chain ID for url "${url}".`,
),
)
}
Expand Down Expand Up @@ -185,8 +186,10 @@ const trackRpcUrl = (
}
}

const timeout = <T>(promise: Promise<T>) =>
const timeout = <T>(promise: Promise<T>, errorMessage: string) =>
Promise.race([
promise,
new Promise<T>((_, reject) => setTimeout(() => reject(), 10_000)),
new Promise<T>((_, reject) =>
setTimeout(() => reject(errorMessage), 10_000),
),
])

0 comments on commit b8891d3

Please sign in to comment.