From 5d1ea79a832a5cfdd16583d780e377379b92147a Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 14 May 2026 14:26:58 -0700 Subject: [PATCH] quic: fix premature unref of endpoint when listening Signed-off-by: James M Snell PR-URL: https://github.com/nodejs/node/pull/63267 Reviewed-By: Matteo Collina --- src/quic/endpoint.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/quic/endpoint.cc b/src/quic/endpoint.cc index 8a61f51b088..46dd0231c4f 100644 --- a/src/quic/endpoint.cc +++ b/src/quic/endpoint.cc @@ -735,7 +735,9 @@ void Endpoint::RemoveSession(const CID& cid, } } if (primary_session_count_ > 0 && --primary_session_count_ == 0) { - udp_.Unref(); + if (!is_listening()) { + udp_.Unref(); + } session_manager().RemoveSession(cid); // The endpoint may be idle (no sessions, not listening). MaybeDestroy // handles both closing (immediate destroy) and idle timeout (start