question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] connectkit (wagmi) is spamming alchemy

See original GitHub issue
Screen Shot 2022-10-23 at 01 09 24

connectkit is sending so many requests to alchemy that it sometimes exceeds concurrent requests limit. You can easily recreate this by going into https://docs.family.co/connectkit/try-it-out and clicking connect, and going in and out of modals several times.

{"jsonrpc":"2.0","id":42,"error":{"code":429,"message":"Your app has exceeded its concurrent requests capacity. If you have retries enabled, you can safely ignore this message. If not, check out https://docs.alchemyapi.io/documentation/rate-limits. Reach out to us if you'd like to increase your limits: https://dashboard.alchemyapi.io/support"}}

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:16 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
lochiecommented, Nov 9, 2022

Hey everyone, I have some answers that will hopefully provide some help:

Solutions

  • Ensure your environment variables match your frameworks requirements (e.g Next.js requires the NEXT_PUBLIC_ prefix, while create-react-app requires the REACT_APP_ prefix), you can test by console.loging out your env variables to double check that it’s being returned correctly.
  • If you are unsure about your env variables setup, or are still having issues, feel free to supply your API key directly into the client configuration instead of env vars, as these variables are client-side anyway and the env var setup is more of a suggestion based on developer standards.
  • Check you have whitelisted your domains within Infura/Alchemy’s dashboards (don’t forget localhost!)

Why the 429 error

If your Infura/Alchemy key has not been passed through to the WagmiClient (or our getDefaultClient) correctly then wagmi will fall back to an Alchemy provider that uses a shared public API key, in which has been severly rate limited (the 429 error).

For reference, the shared API key for wagmi 0.6.x and below is _gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC and can be found in the wagmi codebase here (which you also can see in the error logs that are returning a 429 error).

If you have updated to wagmi 0.7.x you may have noticed the 429 errors going away. The reason behind this is because this version of wagmi uses a different fallback API key, which although is also rate limited, not as many projects are using this version of wagmi – so at this point in time the new public wagmi key succeeds more often than the older version.

Why the spamming

When Alchemy fails to receive data (i.e the 429 error) it has an auto-retry method baked into it. This auto-retry pings the API a few times a second until it receives data, which explains the spamming. A valid API key supplied to the client configuration will stop this issue.

Further debugging

You can check your apps client configurations by using the useProvider hook and looking at the providerConfigs array to see what configured providers are available.

CleanShot 2022-11-10 at 02 27 27@2x

If you don’t see your provider and API key in here then there may be a different issue with your client configuration. Feel free to open a ticket if this occurs.

I hope this helps resolve everyones issues. There’s also some conversations relating to this issue in https://github.com/family/connectkit/issues/36 if anyone else wants some further reading.

2reactions
johnpaulcascommented, Nov 9, 2022

Same here unfortunately. ConnectKit 1.0, have stallTimeout, NEXT_PUBLIC_ALCHEMY_ID. Let me know if need anything else for testing, 🙏

hi @jterskine doing this configuration

const { provider, webSocketProvider } = configureChains(
  supportedChain,
  [
    infuraProvider({ apiKey: infuraId, stallTimeout: 1_000, priority: 0 }),
    alchemyProvider({ apiKey: alchemyId, stallTimeout: 1_000, priority: 1 }),
    publicProvider({ priority: 2 })
  ]
)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error Reference - Alchemy Docs
Error Reference. Learn about the standard JSON-RPC error codes and Alchemy's custom error codes. HTTP Status ...
Read more >
wagmi-dev.eth (@wagmi_sh) / Twitter
PSA: Someone is sending spam to wagmi contributors. Stay vigilant out there!
Read more >
Configuring Chains - wagmi
The configureChains function allows you to configure your chains with providers such as: Alchemy, Infura, or something else. This means you don't need...
Read more >
MOHAWK PUNK - Untitled Collection #189689006 | OpenSea
... arizona arkansas california colorado connecticut delaware florida georgia ... addams ahs alchemy alec baldwin angel angry apocalypse arcade astrology ...
Read more >
Main Categories - Underup
... Jumia Store Nigeria || Fashion · Defi Spammer Announcement ‍ · Kaiiax ... Amp · Fullmetal alchemist |...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found