You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/09/11 06:56:44 UTC

[GitHub] [pulsar-client-node] savearray2 opened a new issue #119: Unhandled Promise Rejection On Failed createProducer

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:
users@infra.apache.org



[GitHub] [pulsar-client-node] savearray2 commented on issue #119: Unhandled Promise Rejection On Failed createProducer

Posted by GitBox <gi...@apache.org>.
savearray2 commented on issue #119:
URL: https://github.com/apache/pulsar-client-node/issues/119#issuecomment-690932567






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar-client-node] savearray2 commented on issue #119: Unhandled Promise Rejection On Failed createProducer

Posted by GitBox <gi...@apache.org>.
savearray2 commented on issue #119:
URL: https://github.com/apache/pulsar-client-node/issues/119#issuecomment-690976782


   Okay, I probably should have done some more research (and gotten more sleep) before posting this. Sorry about this mess.
   The problem with the unhandled promise rejection **is not** with the pulsar library. I had a typo in my testing framework code.
   
   The second problem with the segmentation fault happens when the client is not closed properly before exit. It may be desirable to include code in the library to attach to a process exit to automatically close out the client if it hasn't been already, but this might add unneeded complexity.
   
   The following code fixes the test:
   ```js
   const Pulsar = require('.')
   const client = new Pulsar.Client({
   	serviceUrl: 'pulsar://this-will-fail:6650'
   })
   client.createProducer({
   	topic: 'persistent://a/b/c',
   }).then(() => {
   	console.log('success')
   	client.close()
   }).catch((err) => {
   	console.log('normal err')
   	console.log(err)
   	client.close()
   })
   ```
   
   Please note the inclusion of ```client.close()```.
   
   This issue may be closed at the maintainers' leisure.
   Again, I apologize for the trouble.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar-client-node] savearray2 commented on issue #119: Unhandled Promise Rejection On Failed createProducer

Posted by GitBox <gi...@apache.org>.
savearray2 commented on issue #119:
URL: https://github.com/apache/pulsar-client-node/issues/119#issuecomment-690932567






----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar-client-node] savearray2 commented on issue #119: Unhandled Promise Rejection On Failed createProducer

Posted by GitBox <gi...@apache.org>.
savearray2 commented on issue #119:
URL: https://github.com/apache/pulsar-client-node/issues/119#issuecomment-690932567


   Well, this is strange.
   I cloned the project and created a simple js file to reproduce the error:
   ```js
   const Pulsar = require('.')
   const client = new Pulsar.Client({
   	serviceUrl: 'pulsar://this-will-fail:6650'
   })
   client.createProducer({
   	topic: 'persistent://a/b/c',
   }).then(() => {
   	console.log('success')
   }).catch((err) => {
   	console.log('normal err')
   	console.log(err)
   })
   ```
   
   This leads to the following output:
   ```
   # node test_me.js
   2020-09-11 16:39:03.046 INFO  [0x700008f87000] ConnectionPool:85 | Created connection for pulsar://this-will-fail:6650
   2020-09-11 16:39:03.058 ERROR [0x70000a813000] ClientConnection:469 | [<none> -> pulsar://this-will-fail:6650] Resolve error: asio.netdb:1 : Host not found (authoritative)
   2020-09-11 16:39:03.058 INFO  [0x70000a813000] ClientConnection:1387 | [<none> -> pulsar://this-will-fail:6650] Connection closed
   2020-09-11 16:39:03.058 ERROR [0x70000a813000] ClientImpl:181 | Error Checking/Getting Partition Metadata while creating producer on persistent://a/b/c -- ConnectError
   2020-09-11 16:39:03.058 INFO  [0x70000a813000] ClientConnection:238 | [<none> -> pulsar://this-will-fail:6650] Destroyed connection
   normal err
   [Error: Failed to create producer: ConnectError]
   [1]    45767 segmentation fault  node test_me.js
   ```
   
   This still seems to be related to the comment in the NAPI repository mentioned above. According to the comment, a change needed to be made so that exceptions do not occur on exit.
   
   I'd like to get some input from you guys on how to proceed.


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar-client-node] sijie closed issue #119: Unhandled Promise Rejection On Failed createProducer

Posted by GitBox <gi...@apache.org>.
sijie closed issue #119:
URL: https://github.com/apache/pulsar-client-node/issues/119


   


----------------------------------------------------------------
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:
users@infra.apache.org



[GitHub] [pulsar-client-node] sijie commented on issue #119: Unhandled Promise Rejection On Failed createProducer

Posted by GitBox <gi...@apache.org>.
sijie commented on issue #119:
URL: https://github.com/apache/pulsar-client-node/issues/119#issuecomment-692421212


   @savearray2 thank you for your explanation! Close this issue since it seems that the problem has been resolved.


----------------------------------------------------------------
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:
users@infra.apache.org