savearray2 opened a new issue #119:
URL: https://github.com/apache/pulsar-client-node/issues/119


   When creating a producer using a client URL that is intentionally incorrect 
via the following:
   ```js
   const client = new Pulsar.Client({
        serviceUrl: 'pulsar://this-will-fail:6650',
        ioThreads: 6
   })
   client.createProducer({
        topic: 'persistent://test/a/b',
   }).then((producer) => {
        // ...
   }).catch((err) => {
        // ...
   })
   ```
   
   I get the following unhandled promise rejection warning:
   ```
   [ClientConnection:469] [<none> -> pulsar://this-will-fail:6650] Resolve 
error: asio.netdb:1 : Host not found (authoritative)
   (node:15) UnhandledPromiseRejectionWarning: Error: Failed to create 
producer: ConnectError
   (node:15) UnhandledPromiseRejectionWarning: Unhandled promise rejection. 
This error originated either by throwing inside of an async function without a 
catch block, or by rejecting a promise which was not handled with .catch(). To 
terminate the node process on unhandled promise rejection, use the CLI flag 
`--unhandled-rejections=strict` (see 
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 
1)
   (node:15) [DEP0018] DeprecationWarning: Unhandled promise rejections are 
deprecated. In the future, promise rejections that are not handled will 
terminate the Node.js process with a non-zero exit code.
   ```
   
   Upon further inspection of the code the error originates from the following 
line:
   
https://github.com/apache/pulsar-client-node/blob/eaba0dcd9b8e04fe7c23feb0c0ec6e424a817f64/src/Consumer.cc#L134
   
   Where ```ConsumerNewInstanceWorker``` is a ```Napi::AsyncWorker```:
   
https://github.com/apache/pulsar-client-node/blob/eaba0dcd9b8e04fe7c23feb0c0ec6e424a817f64/src/Consumer.cc#L94-L102
   
   I did some quick checking into using Promises with ```AsyncWorker``` and 
there is a proposed solution mentioned here on the NAPI repository: 
https://github.com/nodejs/node-addon-api/issues/231#issuecomment-528986145
   
   I'd be willing to incorporate this solution and create a pull request, if it 
would be welcome, but I wanted to discuss it here first before making any 
changes.
   
   I'd also be willing to help out with some of the other requests here, as 
well.
   I'll be using this in production going forward.


----------------------------------------------------------------
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


Reply via email to