Skip to content

v17.0.1 & v16.13.0 udp dgram health check bug in cluster model #40671

@introspection3

Description

@introspection3

Version

v17.0.1 & v16.13.0

Platform

ubuntun 20 x64

Subsystem

dgram.js

What steps will reproduce the bug?

https://github.com/nodejs/node/blob/2413283f55ef429764c50c5460dfb04127d13e7a/lib/dgram.js
function healthCheck(socket) {
if (!socket[kStateSymbol].handle) {
// Error message from dgram_legacy.js.
throw new ERR_SOCKET_DGRAM_NOT_RUNNING();
}
}
// use this code below,I check whether the port is Unused,same code works fine in single process but
ocurrs error in cluster model. may in server.close

function isUdpPortUnusedAsync(port) {
port = Number.parseInt(port);
logger.trace('isUdpPortUnusedAsync 1');
let p = new Promise((resolve, reject) => {
const server = dgram.createSocket('udp4');
server.on('error', (err) => {
logger.trace('isUdpPortUnusedAsync err' + err);
server.close();
resolve(false);
});

    server.on('listening', () => {
        logger.trace('isUdpPortUnusedAsync listening 1');
        server.close();
        logger.trace('isUdpPortUnusedAsync listening 2');
        resolve(true);

    });
    logger.trace('isUdpPortUnusedAsync 2');
    server.bind(port);
    logger.trace('isUdpPortUnusedAsync 3');
});
return p;

}

2021-10-31T19:21:56.193 ERROR default 927844 :==>Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
at new NodeError (node:internal/errors:371:5)
at healthCheck (node:dgram:909:11)
at Socket.address (node:dgram:760:3)
at Socket. (node:internal/cluster/child:115:25)
at Object.onceWrapper (node:events:509:28)
at Socket.emit (node:events:402:35)
at startListening (node:dgram:172:10)
at node:dgram:222:5
at shared (node:internal/cluster/child:149:3)
at Worker. (node:internal/cluster/child:106:7)
at process.onInternalMessage (node:internal/cluster/utils:49:5)
at process.emit (node:events:402:35)
at emit (node:internal/child_process:917:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
2021-10-31T19:21:56.193 ERROR default 927844 :==>Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
at new NodeError (node:internal/errors:371:5)
at healthCheck (node:dgram:909:11)
at Socket.address (node:dgram:760:3)
at Socket. (node:internal/cluster/child:115:25)
at Object.onceWrapper (node:events:509:28)
at Socket.emit (node:events:402:35)
at startListening (node:dgram:172:10)
at node:dgram:222:5
at shared (node:internal/cluster/child:149:3)
at Worker. (node:internal/cluster/child:106:7)
at process.onInternalMessage (node:internal/cluster/utils:49:5)
at process.emit (node:events:402:35)
at emit (node:internal/child_process:917:12)
at processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'ERR_SOCKET_DGRAM_NOT_RUNNING'
}

How often does it reproduce? Is there a required condition?

every time

What is the expected behavior?

work fine in cluster model

What do you see instead?

No response

Additional information

if the port is unused,i will create a udpserver

Metadata

Metadata

Assignees

No one assigned

    Labels

    dgramIssues and PRs related to the dgram subsystem / UDP.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions