node icon indicating copy to clipboard operation
node copied to clipboard

src: add UV_PIPE_NO_TRUNCATE for bind in pipe_wrap.cc

Open theanarkh opened this issue 10 months ago • 9 comments

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), or vcbuild test (Windows) passes
  • [x] tests and/or benchmarks are included
  • [x] documentation is changed or added
  • [x] commit message follows commit guidelines

theanarkh avatar Apr 03 '24 14:04 theanarkh

CI: https://ci.nodejs.org/job/node-test-pull-request/58082/

nodejs-github-bot avatar Apr 03 '24 19:04 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58121/

nodejs-github-bot avatar Apr 04 '24 18:04 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58142/

nodejs-github-bot avatar Apr 05 '24 15:04 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58511/

nodejs-github-bot avatar Apr 19 '24 03:04 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58589/

nodejs-github-bot avatar Apr 22 '24 10:04 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58620/ 💛

nodejs-github-bot avatar Apr 23 '24 01:04 nodejs-github-bot

@nodejs/tsc ... this needs another TSC review.

jasnell avatar Apr 27 '24 14:04 jasnell

There was a test, but it seems to be accidentally deleted. Please add it again.

daeyeon avatar Apr 28 '24 07:04 daeyeon

CI: https://ci.nodejs.org/job/node-test-pull-request/58801/

nodejs-github-bot avatar Apr 29 '24 16:04 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58907/

nodejs-github-bot avatar May 03 '24 20:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58911/

nodejs-github-bot avatar May 04 '24 03:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58915/

nodejs-github-bot avatar May 04 '24 06:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58924/

nodejs-github-bot avatar May 04 '24 13:05 nodejs-github-bot

CI: https://ci.nodejs.org/job/node-test-pull-request/58927/

nodejs-github-bot avatar May 04 '24 17:05 nodejs-github-bot

Landed in 75884678d7e7ef228c8f8f82b4c085258c70a823

nodejs-github-bot avatar May 06 '24 12:05 nodejs-github-bot