Skip to content

Commit 185d1ff

Browse files
jasnelladuh95
authored andcommitted
src: improve error handling in node_messaging.cc
PR-URL: #57211 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matthew Aitken <maitken033380023@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent 96b2bfb commit 185d1ff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/node_messaging.cc

+9-4
Original file line numberDiff line numberDiff line change
@@ -1627,10 +1627,15 @@ static void MessageChannel(const FunctionCallbackInfo<Value>& args) {
16271627

16281628
MessagePort::Entangle(port1, port2);
16291629

1630-
args.This()->Set(context, env->port1_string(), port1->object())
1631-
.Check();
1632-
args.This()->Set(context, env->port2_string(), port2->object())
1633-
.Check();
1630+
if (args.This()
1631+
->Set(context, env->port1_string(), port1->object())
1632+
.IsNothing() ||
1633+
args.This()
1634+
->Set(context, env->port2_string(), port2->object())
1635+
.IsNothing()) {
1636+
port1->Close();
1637+
port2->Close();
1638+
}
16341639
}
16351640

16361641
static void BroadcastChannel(const FunctionCallbackInfo<Value>& args) {

0 commit comments

Comments
 (0)