Skip to content

fix: false MaxListenersExceededWarning on GlobalBus during normal event fanout #23798

Closed as not planned

Description

@Brukkil

Description

When multiple consumers subscribe to the shared GlobalBus event channel at the same time, OpenCode can emit Node's MaxListenersExceededWarning even though the subscriptions are part of normal runtime behavior.

Plugins

Observed in a local setup with multiple plugins enabled, but the warning points at the shared GlobalBus fanout path rather than one plugin-specific emitter.

OpenCode version

1.14.19

Steps to reproduce

  1. Run OpenCode with the app/TUI and normal background consumers active
  2. Open overlapping /global/event listeners during reconnects or concurrent consumers
  3. Observe MaxListenersExceededWarning for the shared EventEmitter

Screenshot and/or share link

N/A

Operating System

Ubuntu 22.04

Terminal

zsh on Linux

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 22, 2026
  2. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  3. Rhiz3K commented on May 14, 2026

    @Rhiz3K

    I can reproduce this on 1.14.48 from opencode web, without any plugin involvement.

    This looks less like spooky memory-leak magic and more like the global SSE endpoint doing exactly what Node warns about: every /global/event stream attaches another GlobalBus.on("event", handler), then the 11th concurrent listener trips MaxListenersExceededWarning.

    Repro:

    opencode web --hostname 127.0.0.1 --port 4098

    Then open 11 concurrent SSE clients:

    for i in $(seq 1 11); do timeout 8s curl -Ns http://127.0.0.1:4098/global/event >/dev/null & done

    Actual output:

    MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 event listeners added to [hz]. MaxListeners is undefined. Use events.setMaxListeners() to increase limit
     emitter: hz {
      _events: [Object ...],
      _eventsCount: 1,
      _maxListeners: undefined,
      [Symbol(kCapture)]: false,
      emit: [Function: emit],
      setMaxListeners: [Function: setMaxListeners],
      getMaxListeners: [Function: getMaxListeners],
      addListener: [Function: addListener],
      on: [Function: addListener],
      prependListener: [Function: prependListener],
      once: [Function: once],
      prependOnceListener: [Function: prependOnceListener],
      removeListener: [Function: removeListener],
      off: [Function: removeListener],
      removeAllListeners: [Function: removeAllListeners],
      listeners: [Function: listeners],
      rawListeners: [Function: rawListeners],
      listenerCount: [Function: listenerCount],
      eventNames: [Function: eventNames],
    },
        type: "event",
       count: 11,
    
          at overflowWarning (node:events:185:19)
          at addListener (node:events:158:22)
          at ~effect/Effect/evaluate (/$bunfs/root/chunk-w8ygwpb0.js:25:4492)
          at runLoop (/$bunfs/root/chunk-w8ygwpb0.js:25:2045)
          at evaluate (/$bunfs/root/chunk-w8ygwpb0.js:25:1435)
          at runTasks (/$bunfs/root/chunk-w8ygwpb0.js:11:33426)
          at afterScheduled (/$bunfs/root/chunk-w8ygwpb0.js:11:33313)
    

    Environment:

    OpenCode: 1.14.48
    OS: Ubuntu Linux 6.8.0-111-generic x86_64
    Command: opencode web --hostname 0.0.0.0 --port 4096
    

    Expected: serving multiple legitimate web/SSE clients should not print a memory leak warning during normal operation. If this fanout is expected, GlobalBus probably needs an explicit max listener policy or a different fanout shape so users do not get scared by a false positive warning.

  4. SurealCereal commented on May 16, 2026

    @SurealCereal

    I can reproduce this on 1.14.48 from opencode web, without any plugin involvement.

    Exactly what I saw now with 1.15.3

    opencode server listening on http://127.0.0.1:4096
    MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 event listeners added to [dI]. MaxListeners is undefined. Use events.setMaxListeners() to increase limit
     emitter: dI {
      _events: [Object ...],
      _eventsCount: 1,
      _maxListeners: undefined,
      [Symbol(kCapture)]: false,
      emit: [Function: emit],
      setMaxListeners: [Function: setMaxListeners],
      getMaxListeners: [Function: getMaxListeners],
      addListener: [Function: addListener],
      on: [Function: addListener],
      prependListener: [Function: prependListener],
      once: [Function: once],
      prependOnceListener: [Function: prependOnceListener],
      removeListener: [Function: removeListener],
      off: [Function: removeListener],
      removeAllListeners: [Function: removeAllListeners],
      listeners: [Function: listeners],
      rawListeners: [Function: rawListeners],
      listenerCount: [Function: listenerCount],
      eventNames: [Function: eventNames],
    },
        type: "event",
       count: 11,
    
          at overflowWarning (node:events:185:19)
          at addListener (node:events:158:22)
          at ~effect/Effect/evaluate (/$bunfs/root/chunk-658twvfx.js:25:4492)
          at runLoop (/$bunfs/root/chunk-658twvfx.js:25:2045)
          at evaluate (/$bunfs/root/chunk-658twvfx.js:25:1435)
          at runTasks (/$bunfs/root/chunk-658twvfx.js:11:33531)
          at afterScheduled (/$bunfs/root/chunk-658twvfx.js:11:33418)
    
  5. jasgeo75 commented on May 19, 2026

    @jasgeo75

    Seeing the same with 1.15.5

    opencode server listening on http://0.0.0.0:4096
    /MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 event listeners added to [iI]. MaxListeners is undefined. Use events.setMaxListeners() to increase limit
     emitter: iI {
      _events: [Object ...],
      _eventsCount: 1,
      _maxListeners: undefined,
      [Symbol(kCapture)]: false,
      emit: [Function: emit],
      setMaxListeners: [Function: setMaxListeners],
      getMaxListeners: [Function: getMaxListeners],
      addListener: [Function: addListener],
      on: [Function: addListener],
      prependListener: [Function: prependListener],
      once: [Function: once],
      prependOnceListener: [Function: prependOnceListener],
      removeListener: [Function: removeListener],
      off: [Function: removeListener],
      removeAllListeners: [Function: removeAllListeners],
      listeners: [Function: listeners],
      rawListeners: [Function: rawListeners],
      listenerCount: [Function: listenerCount],
      eventNames: [Function: eventNames],
    },
        type: "event",
       count: 11,
    
          at overflowWarning (node:events:185:19)
          at addListener (node:events:158:22)
          at ~effect/Effect/evaluate (/$bunfs/root/chunk-p8yfbfys.js:25:4492)
          at runLoop (/$bunfs/root/chunk-p8yfbfys.js:25:2045)
          at evaluate (/$bunfs/root/chunk-p8yfbfys.js:25:1435)
          at runTasks (/$bunfs/root/chunk-p8yfbfys.js:11:33531)
          at afterScheduled (/$bunfs/root/chunk-p8yfbfys.js:11:33418)
    
  6. TheAPIguys commented on May 21, 2026

    @TheAPIguys

    Same here. opencode ver v1.15.2. Windows 11 latest update. Print in the terminal: opencode web
    ! OPENCODE_SERVER_PASSWORD is not set; server is unsecured.

                                   ▄
    

    █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
    █ █ █ █ █▀▀▀ █ █ █ █ █ █ █ █▀▀▀
    ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀

    Web interface: http://127.0.0.1:41423/
    MaxListenersExceededWarning: Possible EventTarget memory leak detected. 11 event listeners added to [dI]. MaxListeners is undefined. Use events.setMaxListeners() to increase limit
    emitter: dI {
    _events: [Object ...],
    _eventsCount: 1,
    _maxListeners: undefined,
    [Symbol(kCapture)]: false,
    emit: [Function: emit],
    setMaxListeners: [Function: setMaxListeners],
    getMaxListeners: [Function: getMaxListeners],
    addListener: [Function: addListener],
    on: [Function: addListener],
    prependListener: [Function: prependListener],
    once: [Function: once],
    prependOnceListener: [Function: prependOnceListener],
    removeListener: [Function: removeListener],
    off: [Function: removeListener],
    removeAllListeners: [Function: removeAllListeners],
    listeners: [Function: listeners],
    rawListeners: [Function: rawListeners],
    listenerCount: [Function: listenerCount],
    eventNames: [Function: eventNames],
    },
    type: "event",
    count: 11,

      at overflowWarning (node:events:185:19)
      at addListener (node:events:158:22)
      at ~effect/Effect/evaluate (B:/~BUN/root/chunk-kh42tdx7.js:25:4492)
      at runLoop (B:/~BUN/root/chunk-kh42tdx7.js:25:2045)
      at evaluate (B:/~BUN/root/chunk-kh42tdx7.js:25:1435)
      at runTasks (B:/~BUN/root/chunk-kh42tdx7.js:11:33531)
      at afterScheduled (B:/~BUN/root/chunk-kh42tdx7.js:11:33418)
    
  7. github-actions commented on Jul 20, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions