Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LogSubscription warning MaxListenersExceededWarning: Possible EventTarget memory leak detected. #3624

Open
codemedian opened this issue Nov 25, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@codemedian
Copy link

codemedian commented Nov 25, 2024

Overview

Hi all, I've started playing with the 2.x version of the SDK and pretty happy with it overall. I've now wanted to add 3 logsListeners with a filter of my address for the different commitment levels and while it works fine for 2 logs subscriptions, once I add a 3rd node events gets unhappy with

When I reduce the maxSubscriptionsPerChannel config in the createSolanaRpcSubscriptions to say 2, the warning goes away fyi. The issue varies and sometimes complains about AbortSignal and sometimes about EventTarget

Steps to reproduce

const abortController = new AbortController();
const solanaRpcSubscriptions = createSolanaRpcSubscriptions(...);

const sub1 = solanaRpcSubscriptions.logsNotifications(
        { mentions: ["someAddress"] },
        { commitment: "processed" }).subscribe({abortSignal: abortController.signal}).then(...);
const sub2 = solanaRpcSubscriptions.logsNotifications(
        { mentions: ["someAddress"] },
        { commitment: "confirmed" }).subscribe({abortSignal: abortController.signal}).then(...);
const sub3 = solanaRpcSubscriptions.logsNotifications(
        { mentions: ["someAddress"] },
        { commitment: "finalized" }).subscribe({abortSignal: abortController.signal}).then(...);

Description of bug

I did not expect to see this warning and more so would like for a way to set the limits such that it does not warn

EventTarget warning:

(node:54008) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 error listeners added to EventTarget. MaxListeners is 10. Use events.setMaxListeners() to increase limit
    at [kNewListener] (node:internal/event_target:566:17)
    at EventTarget.addEventListener (node:internal/event_target:679:23)
    at Object.on (/Users/chris/Projects/spot/node_modules/@solana/subscribable/src/data-publisher.ts:28:26)
    at Object.on (/Users/chris/Projects/spot/node_modules/@solana/rpc-subscriptions-spec/src/rpc-subscriptions-channel.ts:38:32)
    at Object.on (/Users/chris/Projects/spot/node_modules/@solana/rpc-subscriptions-spec/src/rpc-subscriptions-pubsub-plan.ts:207:36)
    at Object.createAsyncIterableFromDataPublisher (/Users/chris/Projects/spot/node_modules/@solana/subscribable/src/async-iterable.ts:87:19)
    at Object.subscribe (/Users/chris/Projects/spot/node_modules/@solana/rpc-subscriptions-spec/src/rpc-subscriptions.ts:72:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

AbortSignal warning:

(node:54231) MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 abort listeners added to [AbortSignal]. MaxListeners is 10. Use events.setMaxListeners() to increase limit
    at [kNewListener] (node:internal/event_target:566:17)
    at [kNewListener] (node:internal/abort_controller:240:24)
    at EventTarget.addEventListener (node:internal/event_target:679:23)
    at Object.createAsyncIterableFromDataPublisher (/Users/chris/Projects/spot/node_modules/@solana/subscribable/src/async-iterable.ts:81:17)
    at Object.subscribe (/Users/chris/Projects/spot/node_modules/@solana/rpc-subscriptions-spec/src/rpc-subscriptions.ts:72:20)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@codemedian codemedian added the bug Something isn't working label Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant