Skip to content

cluster: Can't passing http server to worker #15556

@ponury-kostek

Description

@ponury-kostek
  • Version: v8.5.0
  • Platform: Linux michal-KU-7693 4.10.0-35-generic Gitter chat room? #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: cluster

Passing http server instance to worker not working anymore on node v8.5.0, but works on v6.11.3
main.js

"use strict";
const cluster = require('cluster');
if (cluster.isMaster) {
	cluster.setupMaster({exec : __dirname + '/subprocess.js'});
	const subprocess = cluster.fork();
	const server = require('http').createServer();

	server.listen(1337, () => {
		subprocess.send('server', server);
	});
}

subprocess.js

"use strict";
process.on('message', (m, server) => {
	console.log(m, server);
});

net.js:1490
throw new Error('Invalid listen argument: ' + util.inspect(options));
^

Error: Invalid listen argument: { port: null }
at Server.listen (net.js:1490:9)
at new RoundRobinHandle (internal/cluster/round_robin_handle.js:23:17)
at queryServer (internal/cluster/master.js:288:29)
at Worker.onmessage (internal/cluster/master.js:244:5)
at ChildProcess.onInternalMessage (internal/cluster/utils.js:42:8)
at emitTwo (events.js:130:20)
at ChildProcess.emit (events.js:213:7)
at emit (internal/child_process.js:774:12)
at _combinedTickCallback (internal/process/next_tick.js:141:11)
at process._tickCallback (internal/process/next_tick.js:180:9)

Metadata

Metadata

Assignees

No one assigned

    Labels

    clusterIssues and PRs related to the cluster subsystem.httpIssues or PRs related to the http subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions