Skip to content

fix(core): clean up injected switchChain listener on failure#5126

Open
yuyua9 wants to merge 1 commit into
wevm:mainfrom
yuyua9:fix/injected-switchchain-listener-yuyua9
Open

fix(core): clean up injected switchChain listener on failure#5126
yuyua9 wants to merge 1 commit into
wevm:mainfrom
yuyua9:fix/injected-switchchain-listener-yuyua9

Conversation

@yuyua9

@yuyua9 yuyua9 commented May 18, 2026

Copy link
Copy Markdown

Summary

  • remove the injected connector change listener when switchChain fails before the chain-change confirmation arrives
  • keep the listener active for the 4902 wallet_addEthereumChain retry flow, and clean it up if that retry fails
  • add a regression test plus a patch changeset for @wagmi/core

This mirrors the leak pattern fixed for WalletConnect in #5033 and the behavior reported in #5032, but applies it to the injected connector path that still had the same failure cleanup gap.

Tests

  • pnpm dlx @biomejs/biome@2.2.4 check packages/core/src/connectors/injected.ts packages/core/src/connectors/injected.test.ts .changeset/injected-switchchain-listener-leak.md
  • git diff --check HEAD~1..HEAD

Not run successfully:

  • pnpm exec vitest packages/core/src/connectors/injected.test.ts --run (blocked because vitest was unavailable; pnpm install --frozen-lockfile --ignore-scripts repeatedly failed with registry ECONNRESET before dependencies were fully installed)

@vercel

vercel Bot commented May 18, 2026

Copy link
Copy Markdown

@yuyua9 is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented May 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1a5aa86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@wagmi/core Patch
@wagmi/connectors Patch
wagmi Patch
@wagmi/solid Patch
@wagmi/vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant