Skip to content

bug(stream): removing a listener during join notification skips a sibling callback #2029

Closed

Description

@Osraka

Describe the bug

In SDK v12.12.0, removing a listener inside its own subscription callback can cause the next caller on the same topic to miss the join result. This is a follow-up edge case to the callback cleanup added for #2027, not the original reconnect bug.

Steps to reproduce

Using the existing mock WebSocket and PhoenixChannelsTransport helpers (no OpenSea API calls):

  1. Subscribe callers A and B to collection:c1. Each registers an ITEM_SOLD handler and an onSubscribed callback.
  2. In A's onSubscribed, call the unsubscribe function returned by A's .on(...).
  3. Acknowledge the initial phx_join.

A focused test on current main fails at expect(second).toHaveBeenCalledTimes(1) with 0 calls. The same behavior occurs if A removes its handler inside onSubscribeError after a rejected join.

Expected behavior

A and B should each receive one join-result notification. Removing A should not skip B.

Environment

  • Package version: 12.12.0 (main at 8ed5cd6)
  • Node.js version: 22.21.0
  • Operating system: macOS 15.6.1
  • Chain / network: none; offline mock WebSocket

Additional context

callerHandle() splices A from subscription.callbackList when its last handler is removed, while sendJoin() iterates that same array. B shifts into A's index and is skipped. The success, error and timeout paths all iterate the live list.

Locally, iterating a snapshot in those three paths makes both new regression tests pass. With that small change, all 54 transport tests and 1,302 SDK unit tests pass, as do check-types, build, and Biome on the affected files. No live stream or API request was made.

Since this repository mirrors an internal monorepo, I am filing the reproducible bug here first rather than assuming a PR can be merged directly. I can share the focused test and patch if useful.

Activity

  1. ryanio commented on Oct 16, 2026

    @ryanio
    Collaborator

    Thanks for the precise report. Your diagnosis was exactly right, and the mock WebSocket repro made it easy to confirm. The fix from #2030 has been recreated internally and will be in the next @opensea/sdk patch release. Closing this once it ships.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions