Skip to content

cdmq: sync-request fails with Node.js v22 due to IPv6 port binding #167

@atheurer

Description

@atheurer

Description

The cdmq tool fails to index results with Node.js v22 due to the sync-requestsync-rpcget-port dependency chain failing to bind to a local port.

Error

Error: listen EADDRINUSE: address already in use ::
    at Server.setupListenHandle [as _listen2] (node:net:1940:16)
    at Server.listen (node:net:2102:7)
    at get-port/index.js:18:9

Root Cause

sync-rpc uses get-port which calls server.listen(0) without specifying a host. Node.js v22 defaults to binding on :: (IPv6 any). This fails when:

  • IPv6 is disabled at the kernel level (net.ipv6.conf.all.disable_ipv6=1), or
  • There are port conflicts on the IPv6 dual-stack socket

The sync-rpc worker (worker.js:68) also calls server.listen(port) without a host, causing the same issue.

Current Workaround

Patch get-port/index.js and sync-rpc/lib/worker.js to bind to 127.0.0.1:

// get-port/index.js - change getPort(0) to:
getPort({port: 0, host: "127.0.0.1"})

// sync-rpc/lib/worker.js - change:
server.listen(+process.argv[2], "127.0.0.1");

This workaround is fragile and gets overwritten by npm install.

Recommended Fix

Replace sync-request with async HTTP calls using then-request which is already imported in cdm.js (line 3). There are only 3 remaining sync-request call sites:

  • cdm.js:490 — PUT for index definitions
  • cdm.js:809 — POST (noted in code: "This is the only http request remaining that still uses a sync-request")
  • cdm.js:1284 — GET for instance queries

Converting these 3 calls from sync-request to then-request (with await) would eliminate the sync-request / sync-rpc / get-port dependency entirely, resolving the Node.js v22 compatibility issue.

Environment

  • Node.js: v22.22.0
  • sync-request: 6.1.0
  • sync-rpc: 1.3.6
  • get-port: 3.2.0
  • OS: RHEL 9.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Queued

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions