diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 3f7cf26709e57f..7afac60350bae5 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -162,7 +162,10 @@ void PipeWrap::Bind(const FunctionCallbackInfo& args) { PipeWrap* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); node::Utf8Value name(args.GetIsolate(), args[0]); - int err = uv_pipe_bind2(&wrap->handle_, *name, name.length(), 0); + int err = uv_pipe_bind2(&wrap->handle_, + *name, + name.length(), + UV_PIPE_NO_TRUNCATE); args.GetReturnValue().Set(err); } @@ -226,7 +229,12 @@ void PipeWrap::Connect(const FunctionCallbackInfo& args) { ConnectWrap* req_wrap = new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPECONNECTWRAP); int err = req_wrap->Dispatch( - uv_pipe_connect2, &wrap->handle_, *name, name.length(), 0, AfterConnect); + uv_pipe_connect2, + &wrap->handle_, + *name, + name.length(), + UV_PIPE_NO_TRUNCATE, + AfterConnect); if (err) { delete req_wrap; } else { diff --git a/test/parallel/test-net-pipe-with-long-path.js b/test/parallel/test-net-pipe-with-long-path.js new file mode 100644 index 00000000000000..c1f92c926fdbb8 --- /dev/null +++ b/test/parallel/test-net-pipe-with-long-path.js @@ -0,0 +1,25 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); +const fs = require('fs'); +const tmpdir = require('../common/tmpdir'); +tmpdir.refresh(); + +const pipePath = `${tmpdir.path}/${'x'.repeat(1000)}.sock`; + +const server = net.createServer(common.mustNotCall()) + .listen(pipePath) + // It may work on some operating systems + .on('listening', () => { + // The socket file must exsit + assert.ok(fs.existsSync(pipePath)); + server.close(); + }) + .on('error', (error) => { + assert.ok(error.code === 'EINVAL'); + net.connect(pipePath) + .on('error', common.mustCall((error) => { + assert.ok(error.code === 'EINVAL'); + })); + });