You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2018/09/07 09:30:58 UTC

[GitHub] david14142 opened a new issue #120: db.head() can cause UnhandledPromiseRejectionWarning in Node.js even when caught

david14142 opened a new issue #120: db.head() can cause UnhandledPromiseRejectionWarning in Node.js even when caught
URL: https://github.com/apache/couchdb-nano/issues/120
 
 
   <!--- Provide a general summary of the issue in the Title above -->
   
   ## Expected Behavior
   <!--- If you're describing a bug, tell us what should happen -->
   <!--- If you're suggesting a change/improvement, tell us how it should work -->
   Catching errors from db.head() calls shouldn't cause warnings:
   
   ```
   .catch((error) => {
       console.log('Error: ' + error.message);
   });
   ```
   Should just write the error to the console.
   
   ## Current Behavior
   <!--- If describing a bug, tell us what happens instead of the expected behavior -->
   <!--- If suggesting a change/improvement, explain the difference from current behavior -->
   Although the error is handled, Node.js still emits an  `UnhandledPromiseRejectionWarning`
   
   ## Possible Solution
   <!--- Not obligatory, but suggest a fix/reason for the bug, -->
   <!--- or ideas how to implement the addition or change -->
   This appears to be because db.head() is wrapping a call to db.relax(), and not handling promise rejections from the db.relax().  Propagating errors to the new Promise (e.g. by adding something like `.catch((err) => {reject(err)})`  ) should allow errors to be handled by the calling code.
   
   ## 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 -->
   
   ```
   db.head('this-is-not-a-valid-id')
     .then((header) => {console.log(header)})
     .catch((error) => {
       console.log('Error: ' + error.message);
     });
   ```
   
   ## 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 -->
   Currently this just produces a warning message in Node.js. 
   
   ## Your Environment
   <!--- Include as many relevant details about the environment you experienced the bug in -->
   * Version used: 7.0.0
   * Browser Name and version: Node.js 10.9.0
   * Operating System and version (desktop or mobile): macOS 10.13.6 (17G65)
   
   

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


With regards,
Apache Git Services