BewareMyPower commented on code in PR #412: URL: https://github.com/apache/pulsar-client-node/pull/412#discussion_r2079126945
########## src/Client.cc: ########## @@ -138,7 +138,9 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Client>(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<Napi::Object>()); + this->authRef_.SuppressDestruct(); Review Comment: I didn't have time looking deeper for now. But I assume that when the `Client` destructs, the `authRef_` will be destroyed as well unless you call `SuppressDestruct()`. The original issue happens just because `auth` is a local variable that is referenced by the client config's authentication field. However, since it's now a field of `Client`, whose lifetime should be longer than its config. We can now prevent the GC of `auth`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org