Skip to content
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

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

Closed
ponury-kostek opened this issue Sep 22, 2017 · 4 comments
Closed

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

ponury-kostek opened this issue Sep 22, 2017 · 4 comments
Labels
cluster Issues and PRs related to the cluster subsystem. http Issues or PRs related to the http subsystem.

Comments

@ponury-kostek
Copy link

ponury-kostek commented Sep 22, 2017

  • 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)

@ponury-kostek ponury-kostek changed the title passing http server to worker Can't passing http server to worker Sep 22, 2017
@ponury-kostek ponury-kostek changed the title Can't passing http server to worker cluster: Can't passing http server to worker Sep 22, 2017
@cjihrig
Copy link
Contributor

cjihrig commented Sep 22, 2017

This looks like it may be #14205. If so, there is a fix in #14221.

@mscdex mscdex added cluster Issues and PRs related to the cluster subsystem. http Issues or PRs related to the http subsystem. labels Sep 22, 2017
@ponury-kostek
Copy link
Author

I don't think it's net related because it works if child_process used instead

"use strict";
const child_process = require('child_process');
const subprocess = child_process.fork(__dirname + '/subprocess.js');
const server = require('http').createServer();
server.listen(1337, () => {
	subprocess.send('server', server);
});

and this work as expected

@cjihrig
Copy link
Contributor

cjihrig commented Sep 22, 2017

I can reproduce the issue with 8.5.0 and master. After applying the changes in #14221, your provided code runs again.

EDIT: It's also worth mentioning that you're sending an HTTP server to the child process. That will come through on the child side as a net server, not HTTP server.

@ponury-kostek
Copy link
Author

It works in 8.6.0 so I'm closing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

3 participants