connectkit: [BUG] ConnectKit failing requests to Alchemy even though I am using Infura
Describe the bug
I am using ConnectKit with Infura and until recently my website was working fine but now it fails to connect with a bunch of errors to Alchemy in the console.
To reproduce
I am using the following code to connect with ConnectKit:
import {
WagmiConfig,
createClient,
useContractRead,
chain } from "wagmi";
import { ConnectKitProvider, getDefaultClient } from "connectkit";
const contractConfig = {
addressOrName: contractAddress,
contractInterface: abiFile,
};
const client = createClient(
getDefaultClient({
appName: "Chublins",
infuraId: process.env.INFURA_ID,
chains: [chain.mainnet]
}),
);
You can see the full source code of my website here: https://github.com/Montoya/chublins-website/tree/master
The page that used to work fine but now fails is here: https://chublins.com/view
Expected behavior
The view page should load without issues and allow you to enter an ID to view.
Screenshots
Environment details
Latest Google Chrome on MacOS
Additional context
Like I said, this was working fine and then stopped working a couple weeks ago without any code changes.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (6 by maintainers)
Commits related to this issue
- add banner image to readme (#36) — committed to family/connectkit by lochie 2 years ago
Left a big writeup on fixes, debugging and reasons for this issue over in https://github.com/family/connectkit/issues/33#issuecomment-1308935780
@Montoya You can check your clients provider configurations by using the
useProviderhook and looking at theproviderConfigsarray to see what configured providers are going to be used. But you can’t see which one is currently being targeted.I’ve talked with the people over at wagmi about it and there isn’t an easy way to check which provider is currently being targeted due to a limitation with the ethers library. If you feel the need to have this available you can always raise a discussion in the wagmi repo and see where things go from there.
I hope this helps resolve everything! I’m going to close this issue now but if anyone else is still having problems feel free to open your own tickets. 😄
From what I’ve discovered, Alchemy’s API endpoint has started timing out earlier than the Provider’s default
stallTimeout, which then falls back to wagmi’spublicProvider(which also uses Alchemy) which is severely rate limited.To allow for some temporary fixes we’ve now introduced a
stallTimeoutparameter to ourgetDefaultClienthelper in ConnectKit version1.0.0.Update to the latest version of ConnectKit and try something similar to the below, hopefully that will help resolve some issues: