- Version: v8.6.0
- Subsystem: net, cluster
When calling server.listen('./socket.sock') in a worker, the relative path is passed as-is to the master,
causing the path to be relative to the master's CWD, instead of the child process' CWD.
This behavior is inconsistent with listen(...) outside of a worker.
Here's a short example illustrating the issue:
const cluster = require('cluster');
const http = require('http');
if (cluster.isMaster) {
cluster.fork();
} else {
const server = http.createServer();
process.chdir('/tmp');
server.listen("./test.sock");
}
Expected outcome: test.sock is created in /tmp.
Actual outcome: test.sock is created in the previous directory.
Solution:
UNIX domain socket paths should immediately be resolved to absolute paths using path.resolve(...)
before anything else is done with them (such as passing them to the master process).
When calling
server.listen('./socket.sock')in a worker, the relative path is passed as-is to the master,causing the path to be relative to the master's CWD, instead of the child process' CWD.
This behavior is inconsistent with
listen(...)outside of a worker.Here's a short example illustrating the issue:
Expected outcome:
test.sockis created in/tmp.Actual outcome:
test.sockis created in the previous directory.Solution:
UNIX domain socket paths should immediately be resolved to absolute paths using
path.resolve(...)before anything else is done with them (such as passing them to the master process).