From cbbbd0eadf84765705b1b13d045b054380fce93d Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 25 Feb 2025 16:24:25 -0800 Subject: [PATCH] src: improve error handling in node_messaging.cc --- src/node_messaging.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/node_messaging.cc b/src/node_messaging.cc index 9c854df7a3d1f3..d5ef67b15cbd55 100644 --- a/src/node_messaging.cc +++ b/src/node_messaging.cc @@ -1627,10 +1627,15 @@ static void MessageChannel(const FunctionCallbackInfo& args) { MessagePort::Entangle(port1, port2); - args.This()->Set(context, env->port1_string(), port1->object()) - .Check(); - args.This()->Set(context, env->port2_string(), port2->object()) - .Check(); + if (args.This() + ->Set(context, env->port1_string(), port1->object()) + .IsNothing() || + args.This() + ->Set(context, env->port2_string(), port2->object()) + .IsNothing()) { + port1->Close(); + port2->Close(); + } } static void BroadcastChannel(const FunctionCallbackInfo& args) {