wagmi: Error: connection.connector.getProvider is not a function

Describe the bug

Periodically, all functions from hooks (e.g. connect, writeContract / writeContractAsync) fails with connection.connector.getProvider is not a function.

Refreshing page fixes it.

It only occurs with Rabby wallet, Metamask stays connected always and does not run into the issue.

Link to Minimal Reproducible Example

No response

Steps To Reproduce

Nextjs 13+ SSR configured

wagmiConfig.ts

export const wagmiConfig = createConfig({
    // Setup chains
    chains: chains,
    transports: {
        [mainnet.id]: http(),
        [goerli.id]: http(),
        [sepolia.id]: http(),
        [holesky.id]: http()
    },

    // Enable SSR support (needs cookies)
    ssr: true,
    storage: createStorage({
        storage: cookieStorage
    }),

    connectors: [injected()]
});

Web3Provider.tsx

'use client';

// ...

const queryClient = new QueryClient();

const Web3Provider = ({
    children,
    initialState
}: {
    children: React.ReactNode;
    initialState: State;
}) => {
    return (
        <>
            <WagmiProvider config={wagmiConfig} initialState={initialState}>
                <QueryClientProvider client={queryClient}> {children}</QueryClientProvider>
            </WagmiProvider>
        </>
    );
};

layout.tsx

// ...
const initialState = cookieToInitialState(wagmiConfig, headers().get('cookie'));
This may also be relevant: I do not use any 3rd party connector (e.g. ConnectKit, Web3Modal, etc). I just do a simple:

'use client';

// ...

       const { connectors, connect } = useConnect();

        if (!isWalletConnected) {
            try {
                connect({ connector: connectors[0] });
            } catch (e) {
               // ...
            }
        }

Wagmi Version

2.3.1

Viem Version

2.4.0

TypeScript Version

10.9.1

Check existing issues

Anything else?

I think it would be really helpful to know more about how connection.connector.getProvider could occur from a dev perspective, e.g. what is going on. Then we can narrow down why it doesn’t work with Rabby.

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Reactions: 2
  • Comments: 21 (7 by maintainers)

Most upvoted comments

Get the same issue here w/ the latest versions!

ncaught (in promise) TypeError: connection.connector.getProvider is not a function
    at getConnectorClient (getConnectorClient.js:40:49)

repro standing by…

Please try the latest version of Wagmi. If that doesn’t work, then happy to take a look into this.