Skip to content

Commit c253e39

Browse files
deokjinkimUlisesGascon
authored andcommitted
src: handle errors from uv_pipe_connect2()
We need to handle errors from uv_pipe_connect2() because return type is `int`. Fixes: #50652 Refs: #49667 Refs: libuv/libuv#4030 PR-URL: #50657 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: theanarkh <theratliter@gmail.com>
1 parent 4d28ced commit c253e39

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/pipe_wrap.cc

+11-8
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,19 @@ void PipeWrap::Connect(const FunctionCallbackInfo<Value>& args) {
225225

226226
ConnectWrap* req_wrap =
227227
new ConnectWrap(env, req_wrap_obj, AsyncWrap::PROVIDER_PIPECONNECTWRAP);
228-
req_wrap->Dispatch(
228+
int err = req_wrap->Dispatch(
229229
uv_pipe_connect2, &wrap->handle_, *name, name.length(), 0, AfterConnect);
230+
if (err) {
231+
delete req_wrap;
232+
} else {
233+
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(net, native),
234+
"connect",
235+
req_wrap,
236+
"pipe_path",
237+
TRACE_STR_COPY(*name));
238+
}
230239

231-
TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(TRACING_CATEGORY_NODE2(net, native),
232-
"connect",
233-
req_wrap,
234-
"pipe_path",
235-
TRACE_STR_COPY(*name));
236-
237-
args.GetReturnValue().Set(0); // uv_pipe_connect() doesn't return errors.
240+
args.GetReturnValue().Set(err);
238241
}
239242

240243
} // namespace node

0 commit comments

Comments
 (0)