Skip to content

Error when trying to unmonitor from events on the socket in compat mode. #716

Open
@Wayonb

Description

@Wayonb

Describe the bug A clear and concise description of what the bug is.

There is an issue with REST crashing with the new Zeromq in compat mode. The problem happens after a lot of creating and removing sockets. The error of the message Address already in use does not make sense since we are unmonitor from events. Any ideas

{
  level: 'error',
  message: 'zmq unconfirmedAdded/TDNA7QT75RC7B3SFCLW43CNW4J3DUO5K6WTKV3I: connection attempt timed out',
  timestamp: '2025-03-26T01:12:07.562Z'
}
{
  error: Error: Address already in use
      at Socket.unmonitor (/app/node_modules/zeromq/lib/compat.js:376:22)
      at zsocket.close (file:///app/src/connection/zmqUtils.js:79:12)
      at closeWithError (file:///app/src/connection/zmqUtils.js:86:12)
      at Timeout.<anonymous> (file:///app/src/connection/zmqUtils.js:99:4)
      at listOnTimeout (node:internal/timers:581:17)
      at process.processTimers (node:internal/timers:519:7) {
    errno: 98,
    code: 'EADDRINUSE'
  },
  level: 'error',
  message: 'uncaughtException: Address already in use\n' +
    'Error: Address already in use\n' +
    '    at Socket.unmonitor (/app/node_modules/zeromq/lib/compat.js:376:22)\n' +
    '    at zsocket.close (file:///app/src/connection/zmqUtils.js:79:12)\n' +
    '    at closeWithError (file:///app/src/connection/zmqUtils.js:86:12)\n' +
    '    at Timeout.<anonymous> (file:///app/src/connection/zmqUtils.js:99:4)\n' +
    '    at listOnTimeout (node:internal/timers:581:17)\n' +
    '    at process.processTimers (node:internal/timers:519:7)',
  stack: 'Error: Address already in use\n' +
    '    at Socket.unmonitor (/app/node_modules/zeromq/lib/compat.js:376:22)\n' +
    '    at zsocket.close (file:///app/src/connection/zmqUtils.js:79:12)\n' +
    '    at closeWithError (file:///app/src/connection/zmqUtils.js:86:12)\n' +
    '    at Timeout.<anonymous> (file:///app/src/connection/zmqUtils.js:99:4)\n' +
    '    at listOnTimeout (node:internal/timers:581:17)\n' +
    '    at process.processTimers (node:internal/timers:519:7)',
  exception: true,
  date: 'Wed Mar 26 2025 01:12:07 GMT+0000 (Coordinated Universal Time)',
  process: {
    pid: 57,
    uid: 1000,
    gid: 1000,
    cwd: '/app',
    execPath: '/usr/bin/node',
    version: 'v20.19.0',
    argv: [ '/usr/bin/node', '/app/src/index.js', '/userconfig/rest.json' ],
    memoryUsage: {
      rss: 287236096,
      heapTotal: 44974080,
      heapUsed: 42185248,
      external: 22819326,
      arrayBuffers: 19201005
    }
  },
  os: { loadavg: [ 0.07, 0.02, 0 ], uptime: 7022021.5 },
  trace: [
    {
      column: 22,
      file: '/app/node_modules/zeromq/lib/compat.js',
      function: 'Socket.unmonitor',
      line: 376,
      method: 'unmonitor',
      native: false
    },
    {
      column: 12,
      file: 'file:///app/src/connection/zmqUtils.js',
      function: 'zsocket.close',
      line: 79,
      method: 'close',
      native: false
    },
    {
      column: 12,
      file: 'file:///app/src/connection/zmqUtils.js',
      function: 'closeWithError',
      line: 86,
      method: null,
      native: false
    },
    {
      column: 4,
      file: 'file:///app/src/connection/zmqUtils.js',
      function: null,
      line: 99,
      method: null,
      native: false
    },
    {
      column: 17,
      file: 'node:internal/timers',
      function: 'listOnTimeout',
      line: 581,
      method: null,
      native: false
    },
    {
      column: 7,
      file: 'node:internal/timers',
      function: 'process.processTimers',
      line: 519,
      method: 'processTimers',
      native: false
    }
  ],
  timestamp: '2025-03-26T01:12:07.564Z'
}

Reproducing If possible, provide a list of commands or a code sample that
reproduces the bug that you are observing. Otherwise please describe as much as
possible in which circumstances the bug can be observed.

Do not have a repo currently, except that it happens after a lot of const zsocket = zmq.socket('sub'); and disconnection.
code is here
Expected behavior A clear and concise description of what you expected to
happen.
not to crash.
Tested on

  • OS: Ubuntu 24.04 ARM64
  • ZeroMQ.js version: 6.3.0 compat mode

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions