Skip to content

Infinite loop when reconnecting causes memory exhaustion #7131

@rnbrady

Description

@rnbrady

In Cashonize Bitcoin cash wallet which uses WalletConnect with a custom network for BCH, after some combination of the tab being backgrounded and network being interrupted, an infinite loop causes a rapid build up of errors until memory is exhausted with the browser tab exceeding 4GB and millions event listerners.

SDK Version (if relevant)

  • Client: Javascript
  • Version: 2.21.8

To Reproduce
Working on reproduction.

Expected behavior
Wallet and app reconnect after a network interruption without excessive resource utilisation.

Video and screenshot

Screen.Recording.2026-01-15.at.12.15.16.mov
Image

Desktop (please complete the following information):

  • OS: MacOS 14.7.4
  • Browsers: Brave 1.85.20, Chrome 143.0.7499

Debugging indicated a flood of calls to Relayer.connect() in relayer.ts. This class has complex retry logic with loops, recursion and circular dependencies which have the potentional to create large numbers of websocket connections and events listeners.

The core.crypto.signJWT(this.relayUrl) makes each attempt expensive and there are hundreds to thousands of attempts per second.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions