From 98a757aea8736f05e93c96c541936e3ff7853172 Mon Sep 17 00:00:00 2001 From: Charles Ede Date: Tue, 6 May 2025 21:36:54 +0100 Subject: [PATCH 1/2] Add persistent reference to Auth Object --- src/Client.cc | 4 +++- src/Client.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Client.cc b/src/Client.cc index a9df576..5f5328b 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -138,7 +138,9 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap(info) if (clientConfig.Has(CFG_AUTH) && clientConfig.Get(CFG_AUTH).IsObject()) { Napi::Object obj = clientConfig.Get(CFG_AUTH).ToObject(); if (obj.Has(CFG_AUTH_PROP) && obj.Get(CFG_AUTH_PROP).IsObject()) { - Authentication *auth = Authentication::Unwrap(obj.Get(CFG_AUTH_PROP).ToObject()); + this->authRef_ = Napi::Persistent(obj.Get(CFG_AUTH_PROP).As()); + this->authRef_.SuppressDestruct(); + Authentication *auth = Authentication::Unwrap(this->authRef_.Value()); pulsar_client_configuration_set_auth(cClientConfig.get(), auth->GetCAuthentication()); } } diff --git a/src/Client.h b/src/Client.h index ee81bb5..b761d36 100644 --- a/src/Client.h +++ b/src/Client.h @@ -54,6 +54,7 @@ class Client : public Napi::ObjectWrap { std::shared_ptr cClient; std::shared_ptr cClientConfig; pulsar_logger_level_t logLevel = pulsar_logger_level_t::pulsar_INFO; + Napi::ObjectReference authRef_; Napi::Value CreateProducer(const Napi::CallbackInfo &info); Napi::Value Subscribe(const Napi::CallbackInfo &info); From ab8ba30efaa2e967960c2cc8843449694c9dbfbb Mon Sep 17 00:00:00 2001 From: Yunze Xu Date: Thu, 8 May 2025 16:00:52 +0800 Subject: [PATCH 2/2] Update src/Client.cc --- src/Client.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Client.cc b/src/Client.cc index 5f5328b..4c6c1fa 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -139,7 +139,6 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap(info) Napi::Object obj = clientConfig.Get(CFG_AUTH).ToObject(); if (obj.Has(CFG_AUTH_PROP) && obj.Get(CFG_AUTH_PROP).IsObject()) { this->authRef_ = Napi::Persistent(obj.Get(CFG_AUTH_PROP).As()); - this->authRef_.SuppressDestruct(); Authentication *auth = Authentication::Unwrap(this->authRef_.Value()); pulsar_client_configuration_set_auth(cClientConfig.get(), auth->GetCAuthentication()); }