lewmelvin opened a new issue #112: UnhandledPromiseRejectionWarning in nano 7.0.0 when using callbacks URL: https://github.com/apache/couchdb-nano/issues/112 <!--- Provide a general summary of the issue in the Title above --> I have an application that currently uses nano 6.4.0 and I've been testing nano 7.0.0. My current implementation uses the callback technique exclusively. All nano calls are provided a callback function to handle the data and errors. I am not using the promise that is returned. Unfortunately, in error situations, there are UnhandledPromiseRejectionWarning messages in the console despite the fact that the provided callback is handling the errors. ## Expected Behavior <!--- If you're describing a bug, tell us what should happen --> If a nano API is called with a callback, the promise should not be created or returned. If a callback is not provided, then a promise should be created and returned. <!--- If you're suggesting a change/improvement, tell us how it should work --> The nano API should only return a promise when a callback is not provided. It should be a either callback or promise, and not require promise handling. ## Current Behavior <!--- If describing a bug, tell us what happens instead of the expected behavior --> When an error occurs, the callback I've provided to the nano calls handles the error situation correctly. I am not doing anything with the promise that is returned. However, there are warnings in the console about UnhandledPromiseRejectionWarning. <!--- If suggesting a change/improvement, explain the difference from current behavior --> nano 6.x did not return promises, so this issue did not occur. ## Possible Solution <!--- Not obligatory, but suggest a fix/reason for the bug, --> <!--- or ideas how to implement the addition or change --> ## Steps to Reproduce (for bugs) <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug. Include code to reproduce, if relevant --> 1. Make a nano call to get a document ID that does not exist. The call should provide a callback with err and body parameters. 2. The callback should console log the error and body objects. 3. Run the code, and observe the UnhandledPromiseRejectionWarning error that appears. 4. If the get call includes a ".catch( () => {} );", the unnecessary promise rejection gets eaten. But this is not a good coding workaround. ## Context <!--- How has this issue affected you? What are you trying to accomplish? --> <!--- Providing context helps us come up with a solution that is most useful in the real world --> The application I have written is a couchdb data store driver for node-workflow. These warnings make it difficult to migrate to nano 7.x. I'm concerned that in the future, these warnings will become real errors and the application will crash due to unhandled promise rejections. I do not want to add unnecessary catch statements to eat the unnecessary rejections. ## Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * Version used: nano 7.0.0 * Browser Name and version: Chrome * Operating System and version (desktop or mobile): Linux RHEL 7.6 * Link to your project:
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
