src: handle errors from uv_pipe_connect2()

We need to handle errors from uv_pipe_connect2()
because return type is `int`.

Fixes: https://github.com/nodejs/node/issues/50652
Refs: https://github.com/nodejs/node/pull/49667
Refs: https://github.com/libuv/libuv/pull/4030
PR-URL: https://github.com/nodejs/node/pull/50657
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: theanarkh <theratliter@gmail.com>
This commit is contained in:
Deokjin Kim authored and GitHub committed 2023-11-12 14:52:03 +00:00
1 parent 0ee49c8620
commit 9134f4ac9b
1 file changed
+11 -8
+11 -8
View File
@@ -225,16 +225,19 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
ConnectWrap* req_wrap =
new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPECONNECTWRAP);
req_wrap->Dispatch(
int err = req_wrap->Dispatch(
uv_pipe_connect2, &wrap->handle_, *name, name.length(), 0, AfterConnect);
if (err) {
delete req_wrap;
} else {
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(net, native),
"connect",
req_wrap,
"pipe_path",
TRACE_STR_COPY(*name));
}
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(net, native),
"connect",
req_wrap,
"pipe_path",
TRACE_STR_COPY(*name));
args.GetReturnValue().Set(0); // uv_pipe_connect() doesn't return errors.
args.GetReturnValue().Set(err);
}
} // namespace node