apache/pulsar-client-node

libc++abi: terminating with uncaught exception of type std::invalid_argument: The scheme part is missing:

trevordowdle opened this issue · 3 comments

In the latest version of Pulsar Client (8.1).

When I initiate a new PulsarClient, if the service url is an empty string or not a valid url I get the following error and my node application/process stops.

libc++abi: terminating with uncaught exception of type std::invalid_argument: The scheme part is missing:

shibd commented

In the CPP client impl, this is expected behavior.

https://github.com/apache/pulsar-client-cpp/blob/40d45aa181847f77c6c8d1f316e5698fffaf2a7a/include/pulsar/Client.h#L55-L56

In the node.js client side, what should we do better? Wrapper this exception?

For some additional context, I recently upgraded an existing project to 1.8.1 from 1.7.0 and we had some configurations that would loop over different pulsar environments to create client connections. A number of these configurations had empty strings for url's when running locally.

Where previously this would fail gracefully, all of a sudden the application just died with the above error message. There was no additional traceable information in order to locate the source of the error.

So I had to take the application apart little by little and finally found the source/cause of the error, but it took a good amount of time and almost dissuaded me from upgrading.

If anything can be done here, I think it would be beneficial, especially for those looking to upgrade from previous versions as the error is not easy to diagnose.

Thanks

This design is to fail fast because an empty string or another invalid service URL should be exposed earlier. It's also consistent with the Java client.

I think when we wrapped this exception for Node.js client, we can catch the std::invalid_argument and wrap the exception as the exception in Node.js. But we should not swallow the exception. An invalid URL could fail the following steps.