web3modal icon indicating copy to clipboard operation
web3modal copied to clipboard

Connection declined. Connection can be declined if a previous request is still active

Open Ay7ot opened this issue 1 year ago • 12 comments

Discussed in https://github.com/orgs/WalletConnect/discussions/4310

Originally posted by Ay7ot March 9, 2024 This is my first time working with Web3Modal and I'm using react. I'm running into a kind of bug. When Itry to connect from a mobile browser or a browser that doesn't have an extension installed, i get the error Connection declined. Connection can be declined if a previous request is still active. My Context provider code looks like this: `import { createWeb3Modal } from '@web3modal/wagmi/react' import { defaultWagmiConfig } from '@web3modal/wagmi/react/config' import { injected, metaMask, safe, walletConnect } from 'wagmi/connectors' import { WagmiProvider } from 'wagmi' import { arbitrum, mainnet } from 'wagmi/chains' import { QueryClient, QueryClientProvider } from '@tanstack/react-query'

// 0. Setup queryClient const queryClient = new QueryClient()

// 1. Get projectId at https://cloud.walletconnect.com const projectId = 'MY_PROJECT_ID'

// 2. Create wagmiConfig const metadata = { name: 'Web3Modal', description: 'Web3Modal Example', url: 'http://localhost:5173', // origin must match your domain & subdomain icons: ['https://avatars.githubusercontent.com/u/37784886'] }

const chains = [mainnet, arbitrum] const config = defaultWagmiConfig({ chains, // required projectId, // required metadata, // required

enableWalletConnect: true, // Optional - true by default
enableInjected: true, // Optional - true by default
enableEIP6963: true, // Optional - true by default
enableCoinbase: true, // Optional - true by default

})

// 3. Create modal createWeb3Modal({ wagmiConfig: config, projectId, enableAnalytics: true // Optional - defaults to your Cloud configuration })

export function ContextProvider({ children }) { return ( <WagmiProvider config={config}> <QueryClientProvider client={queryClient}>{children}</QueryClientProvider> </WagmiProvider> ) }`

I basically followed the doc on installation and I dont know why this is happening. My button is in my app folder and yes, i wrapped my App in ContextProvider.

Ay7ot avatar Mar 09 '24 15:03 Ay7ot

Any update on this? Currently experiencing the same error.

0xSzeth avatar Apr 17 '24 20:04 0xSzeth

Having this same issue

ifeoluwaayo avatar Apr 26 '24 19:04 ifeoluwaayo

Literally dealing with same thing right now. I have no connection windows open or anything.

imjakechapman avatar Apr 29 '24 18:04 imjakechapman

I'm also facing the same problem.

yaman1337 avatar Apr 30 '24 06:04 yaman1337

We are on the same league. Waiting hero to come now.

socheatleang avatar May 10 '24 09:05 socheatleang

Over 1 month later, I'm experience this issue. Any updates?

vectris-dev avatar Jun 12 '24 05:06 vectris-dev

Still active.

lorraineS avatar Jul 15 '24 14:07 lorraineS

still this issue is there ? 💔

manish252488 avatar Jul 19 '24 11:07 manish252488

Oh mine. I am facing this right now.

Well, OK. I think I should

  1. just show "Account" modal, since the error message. says "previous request is still active",
  2. or call wagmi disconnect() then show this connect modal.

Cool!

ghost avatar Aug 26 '24 08:08 ghost

Had to subscribe to this as facing similar issues

rhamnett avatar Aug 30 '24 17:08 rhamnett

This error just hit me this morning, any updates please??

JoshFransix avatar Sep 11 '24 06:09 JoshFransix

also got this issue today

DmitriyStoyanov1 avatar Oct 22 '24 16:10 DmitriyStoyanov1

I'm facing the same problem too. Looking forward to a good solution

zhanzhanxi avatar Oct 23 '24 10:10 zhanzhanxi

Same here, "Connection Declined - Connection can be declined if a previous request is still active".

Impossible to connect from our Expo app on both Wagmi and Ethers.

AnesBkdm avatar Oct 24 '24 05:10 AnesBkdm

I'm also facing this problem. I'm using Vue, ethers, and reown.

MartinLi-coder avatar Oct 26 '24 12:10 MartinLi-coder

I'm also this problem. usign Nextjs, wagmi, viem and reown.

DillonMemo avatar Oct 28 '24 04:10 DillonMemo

为什么这个插件ios18版本以下不能链接钱包,这个要怎么改

yifebbg avatar Oct 28 '24 08:10 yifebbg

Why can't this plugin link to wallets below iOS 18 version? How can I change this

yifebbg avatar Oct 28 '24 08:10 yifebbg

  • [x] Same problem here. If they don't fix it, I will switch to another service to meet deadline.

I had to update the package to 1.2.0 and all problems disappeared. Thanks for fixing it in 1.1.8.

VanessaPC avatar Oct 31 '24 09:10 VanessaPC

  • [x] Same problem here. If they don't fix it, I will switch to another service to meet deadline.

I had to update the package to 1.2.0 and all problems disappeared. Thanks for fixing it in 1.1.8.

BTW @reown/appkit-adapter-wagmi must be updated too

basileos avatar Oct 31 '24 17:10 basileos

Facing same issue on mobile when accessing through browser.I tried with both version 1.2.0 and 1.1.8 and updated "reown/appkit" ,"reown/appkit-adapter-wagmi" both to same version but still not working

shashankpandey56 avatar Nov 04 '24 17:11 shashankpandey56

The initial issue is too old ... can someone share a minimal reproducible example, share a video or give us more context to we can repro it !

Thanks :)

rtomas avatar Nov 06 '24 03:11 rtomas

The initial issue is too old ... can someone share a minimal reproducible example, share a video or give us more context to we can repro it !

Thanks :)

I am having the same issue on mobile when trying to connect from "Browser Wallet" in the modal. If I choose the specific wallet from the other wallets option it connects successfully, but Metamask is not present there so users using Metamask should use the embedded browser inside metamask. I am literally using the same config as in the example repo https://github.com/reown-com/appkit/tree/main/examples/next-wagmi-app-router

I have connected the phone to the pc so as to inspect the console via Chrome but there were no errors.

Screenshot_20241117-200615_Chrome~2.png

The OS of the phone doesn't matter, happening on Android and iOS

All the other functionalities work (Connections via PC, from "All Wallets" option also I have tried a couple of wallets such as Zerion and it's working) I have also tried from mobile Brave Browser. The modal detects the brave wallet and it shows it as a first option, but same error connection declined.

I'm using the latest versions 1.4.1 of appkit, appkit-wagmi-adapters

KAlamurov avatar Nov 17 '24 18:11 KAlamurov

hi @KAlamurov, Browser waller in a known issue. where are going to solve it ASAP. https://linear.app/reown/issue/APKT-1432/[bug]-browser-wallet-is-showing-in-all-mobile-web-an-its-falling

rtomas avatar Nov 17 '24 20:11 rtomas

Thanks @rtomas 🙏

KAlamurov avatar Nov 17 '24 21:11 KAlamurov

@rtomas @KAlamurov any news?

pactamah11 avatar Nov 21 '24 17:11 pactamah11

Nope, still the same with 1.5.0 > @rtomas @KAlamurov any news?

KAlamurov avatar Nov 21 '24 17:11 KAlamurov

ecerpeincing same issue when trying to connect to metamask

Connection declined Connection can be declined if a previous request is still active

'use client';

import { wagmiAdapter, projectId } from '@/config'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { createAppKit } from '@reown/appkit/react'; import { flare } from '@reown/appkit/networks'; import React, { ReactNode } from 'react'; import { cookieToInitialState, WagmiProvider, Config } from 'wagmi'; import NetworkLogger from '@/components/NetworkLogger'; // New component to handle logging

// Set up queryClient const queryClient = new QueryClient();

if (!projectId) { throw new Error('Project ID is not defined'); }

// Set up metadata const metadata = { name: 'Billi Bears Rarity DApp', description: 'A DApp to find the rarest or non-rarest Billi Da Bears NFTs.', url: 'https://appkitexampleapp.com', // origin must match your domain & subdomain icons: ['https://billidabear.vercel.app/assets/images/BearLogo.png'], };

// Create the modal createAppKit({ adapters: [wagmiAdapter], projectId,

networks: [flare], defaultNetwork: flare, enableWalletConnect: true, metadata: metadata, debug: true, chainImages: { 14: 'https://docs.flare.network/assets/images/dev/reference/logo-FLR.png', }, features: { analytics: true, // Optional - defaults to your Cloud configuration }, tokens: { "eip155:14": { address: '0x01E396a10080eC2838D615162B17940b45D5E227', image: 'https://billidabear.vercel.app/assets/images/BearLogo.png' //optional }, } });

function ContextProvider({ children, cookies }: { children: ReactNode; cookies: string | null }) { const initialState = cookieToInitialState(wagmiAdapter.wagmiConfig as Config, cookies);

return ( <WagmiProvider config={wagmiAdapter.wagmiConfig as Config} initialState={initialState}> <QueryClientProvider client={queryClient}> <NetworkLogger /> {/* Logs network and account info */} {children} </QueryClientProvider> </WagmiProvider> ); }

export default ContextProvider;

import { cookieStorage, createStorage } from '@wagmi/core'; import { WagmiAdapter } from '@reown/appkit-adapter-wagmi'; import { flare } from '@reown/appkit/networks';

// Get projectId from environment variable export const projectId = process.env.NEXT_PUBLIC_PROJECT_ID;

if (!projectId) { throw new Error('Project ID is not defined'); }

export const networks = [ flare];

// Set up the Wagmi Adapter export const wagmiAdapter = new WagmiAdapter({ storage: createStorage({ storage: cookieStorage }), ssr: true, projectId, networks });

export const config = wagmiAdapter.wagmiConfig;

import type { Metadata } from 'next'; import { Inter } from 'next/font/google'; import './globals.css'; import CustomCursor from '@/components/Landing-Page-Components/CustomCursor'; import Header from '@/components/Landing-Page-Components/Header'; import Footer from '@/components/Landing-Page-Components/Footer'; import PageLoader from '@/components/Loader/PageLoader'; import ContextProvider from '@/context'; import AuthLayout from '@/components/AuthLayout'; import Script from 'next/script'; import { headers } from 'next/headers'; import { ChakraProvider } from '@chakra-ui/react'; import { TooltipProvider } from '@radix-ui/react-tooltip';

const inter = Inter({ subsets: ['latin'] });

export const metadata: Metadata = { title: 'AppKit Example App', description: 'Powered by Reown', };

export default async function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { // Safely fetch cookies using headers() const cookies = (await headers()).get('cookie') ?? null;

return (

<Script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js" strategy="lazyOnload" /> <meta charSet="UTF-8" /> {String(metadata.title ?? '')} <meta name="description" content={metadata.description ?? ''} /> <body className={inter.className}> <TooltipProvider> <ChakraProvider> <PageLoader> <CustomCursor /> <ContextProvider cookies={cookies}> <Header /> <AuthLayout>{children}</AuthLayout> <Footer /> </ContextProvider> </PageLoader> </ChakraProvider> </TooltipProvider>

DevMarc16 avatar Nov 27 '24 21:11 DevMarc16

issue solved: for me i had to restart extension

DevMarc16 avatar Nov 27 '24 21:11 DevMarc16