-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unhandled Promise Rejection On Failed createProducer #119
Comments
Well, this is strange. 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:
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. |
Okay, I probably should have done some more research (and gotten more sleep) before posting this. Sorry about this mess. 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: 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 This issue may be closed at the maintainers' leisure. |
@savearray2 thank you for your explanation! Close this issue since it seems that the problem has been resolved. |
When creating a producer using a client URL that is intentionally incorrect via the following:
I get the following unhandled promise rejection warning:
Upon further inspection of the code the error originates from the following line:
pulsar-client-node/src/Consumer.cc
Line 134 in eaba0dc
Where
ConsumerNewInstanceWorker
is aNapi::AsyncWorker
:pulsar-client-node/src/Consumer.cc
Lines 94 to 102 in eaba0dc
I did some quick checking into using Promises with
AsyncWorker
and there is a proposed solution mentioned here on the NAPI repository: nodejs/node-addon-api#231 (comment)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.
The text was updated successfully, but these errors were encountered: