k2la opened a new pull request #106: URL: https://github.com/apache/pulsar-client-node/pull/106
### Motivation When the following code is executed, the node process is not finished in spite of consuming all messages and closing the consumer and client. ``` const Pulsar = require('pulsar-client'); (async () => { const client = new Pulsar.Client({ serviceUrl: 'pulsar://localhost:6650', }); let received = 0; let finish; const finishPromise = new Promise((resolve) => { finish = resolve; }); const consumer = await client.subscribe({ topic: 'persistent://public/default/my-topic', subscription: 'sub1', listener: (msg, msgConsumer) => { const data = msg.getData().toString(); console.log(data); msgConsumer.acknowledge(msg); received += 1; if (received === 10) finish(); }, }); await finishPromise; await consumer.close(); await client.close(); })(); ``` It seems that this happens because the registered listener function is not released. https://github.com/apache/pulsar-client-node/blob/master/src/Consumer.cc#L307 `this->listener->callback.Release();` is not executed because `this->listener` becomes `nullptr` when consumers are closed. ### Modification Fix so that the registered listener function is released when the consumer is closed. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org