-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
v17.0.1 & v16.13.0 udp dgram health check bug in cluster model #40671
Labels
dgram
Issues and PRs related to the dgram subsystem / UDP.
Comments
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
This comment was marked as abuse.
VoltrexKeyva
added
the
dgram
Issues and PRs related to the dgram subsystem / UDP.
label
Oct 31, 2021
introspection3
changed the title
udp health check bug in cluster model
v17.0.1 & v16.13.0 udp dgram health check bug in cluster model
Nov 1, 2021
A workaround is to set const dgram = require('dgram')
const cluster = require('cluster')
if (cluster.isMaster) {
cluster.fork()
} else {
function isUdpPortUnusedAsync(port) {
port = Number.parseInt(port);
let p = new Promise((resolve, reject) => {
const server = dgram.createSocket('udp4');
server.on('error', (err) => {
server.close();
resolve(false);
});
server.on('listening', () => {
server.close();
resolve(true);
});
// server.bind(port);
// A workaround is to set "exclusive" true
server.bind({
port,
exclusive: true,
})
});
return p;
}
isUdpPortUnusedAsync(3000).then(console.log)
} |
nodejs-github-bot
pushed a commit
that referenced
this issue
Jul 11, 2022
This fixes closing dgram sockets right after binding in cluster workers will throws `ERR_SOCKET_DGRAM_NOT_RUNNING` errors. PR-URL: #43709 Fixes: #40671 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos
pushed a commit
that referenced
this issue
Jul 12, 2022
This fixes closing dgram sockets right after binding in cluster workers will throws `ERR_SOCKET_DGRAM_NOT_RUNNING` errors. PR-URL: #43709 Fixes: #40671 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos
pushed a commit
that referenced
this issue
Jul 20, 2022
This fixes closing dgram sockets right after binding in cluster workers will throws `ERR_SOCKET_DGRAM_NOT_RUNNING` errors. PR-URL: #43709 Fixes: #40671 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos
pushed a commit
that referenced
this issue
Jul 31, 2022
This fixes closing dgram sockets right after binding in cluster workers will throws `ERR_SOCKET_DGRAM_NOT_RUNNING` errors. PR-URL: #43709 Fixes: #40671 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
guangwong
pushed a commit
to noslate-project/node
that referenced
this issue
Oct 10, 2022
This fixes closing dgram sockets right after binding in cluster workers will throws `ERR_SOCKET_DGRAM_NOT_RUNNING` errors. PR-URL: nodejs/node#43709 Fixes: nodejs/node#40671 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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);
});
}
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
The text was updated successfully, but these errors were encountered: