diff --git a/lib/dgram.js b/lib/dgram.js index c59fdf8a4af11e..01bed97025ebf4 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -199,10 +199,7 @@ function bufferSize(self, size, buffer) { } // Query primary process to get the server handle and utilize it. -function bindServerHandle(self, options, errCb) { - if (!cluster) - cluster = require('cluster'); - +function bindServerHandle(cluster, self, options, errCb) { const state = self[kStateSymbol]; cluster._getServer(self, options, (err, handle) => { if (err) { @@ -266,7 +263,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { cluster = require('cluster'); if (cluster.isWorker && !exclusive) { - bindServerHandle(this, { + bindServerHandle(cluster, this, { address: null, port: null, addressType: this.type, @@ -335,7 +332,7 @@ Socket.prototype.bind = function(port_, address_ /* , callback */) { flags |= UV_UDP_IPV6ONLY; if (cluster.isWorker && !exclusive) { - bindServerHandle(this, { + bindServerHandle(cluster, this, { address: ip, port: port, addressType: this.type,