node
node copied to clipboard
src: add UV_PIPE_NO_TRUNCATE for bind in pipe_wrap.cc
Binding a pipe path that is too long can cause problems and confuse the user.
example1:
const net = require('net');
const fs = require('fs');
const filePath = `/tmp/${'x'.repeat(1000)}.sock`;
const server = net.createServer()
// the path will be truncated
.listen(filePath)
.on('listening', () => {
// here will output true but the socket is not actually bound to filePath
console.log(server.address() === filePath);
// here will output false because the file do not exist
console.log(fs.existsSync(filePath))
})
example2:
const net = require('net');
const filePath1 = `/tmp/${'x'.repeat(1001)}.sock`;
const filePath2 = `/tmp/${'x'.repeat(1002)}.sock`;
// listen successfully
net.createServer().listen(filePath1);
// here will fail with EADDRINUSE error
net.createServer().listen(filePath2);
I think it is better to throw an error when the pipe path is truncated. But it maybe a breaking change.
- [x]
make -j4 test
(UNIX), orvcbuild test
(Windows) passes - [x] tests and/or benchmarks are included
- [x] documentation is changed or added
- [x] commit message follows commit guidelines
CI: https://ci.nodejs.org/job/node-test-pull-request/58082/
CI: https://ci.nodejs.org/job/node-test-pull-request/58121/
CI: https://ci.nodejs.org/job/node-test-pull-request/58142/
CI: https://ci.nodejs.org/job/node-test-pull-request/58511/
CI: https://ci.nodejs.org/job/node-test-pull-request/58589/
CI: https://ci.nodejs.org/job/node-test-pull-request/58620/ 💛
@nodejs/tsc ... this needs another TSC review.
There was a test, but it seems to be accidentally deleted. Please add it again.
CI: https://ci.nodejs.org/job/node-test-pull-request/58801/
CI: https://ci.nodejs.org/job/node-test-pull-request/58907/
CI: https://ci.nodejs.org/job/node-test-pull-request/58911/
CI: https://ci.nodejs.org/job/node-test-pull-request/58915/
CI: https://ci.nodejs.org/job/node-test-pull-request/58924/
CI: https://ci.nodejs.org/job/node-test-pull-request/58927/
Landed in 75884678d7e7ef228c8f8f82b4c085258c70a823