massakam commented on pull request #182: URL: https://github.com/apache/pulsar-client-node/pull/182#issuecomment-986434813
@rickyes This phenomenon does not always occur. It happens when `data->consumer` is accessed in the following part before it is initialized. https://github.com/apache/pulsar-client-node/blob/50c090678ecedaa06e2c68ce1db3046655a9a075/src/Consumer.cc#L62-L65 Adding sleep to the following part will almost certainly reproduce this issue. ```diff --- a/src/Consumer.cc +++ b/src/Consumer.cc @@ -23,6 +23,7 @@ #include "MessageId.h" #include <pulsar/c/result.h> #include <atomic> +#include <chrono> #include <thread> Napi::FunctionReference Consumer::constructor; @@ -163,6 +164,7 @@ class ConsumerNewInstanceWorker : public Napi::AsyncWorker { Consumer *consumer = Consumer::Unwrap(obj); consumer->SetCConsumer(this->consumerWrapper); + std::this_thread::sleep_for(std::chrono::seconds(5)); consumer->SetListenerCallback(this->listener); this->deferred.Resolve(obj); } ``` -- 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: dev-unsubscr...@pulsar.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org