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 2021/11/03 13:21:20 UTC

[GitHub] [couchdb-nano] davidretireup opened a new issue #282: Status resolve/reject

davidretireup opened a new issue #282:
URL: https://github.com/apache/couchdb-nano/issues/282


   <!--- Provide a general summary of the issue in the Title above -->
   The handling of 400 level statusCodes via error callback or reject is not backward compatible after 9.0.1 (due to changes in axios somewhere around 0.21.1)
   
   ## 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 -->
   
   In the following code example, if a database does not exist when using nano 9.0.1 or earlier, `exists` would be true if `missing_db` does not exist:
   
       const {db} = require('nano')({
           url: 'http://some-db.server.com:5984/',
           parseUrl: false
       })
       const exists = await db.get('missing_db')
           .then(() => true)
           .catch(err => err.statusCode === 404 ? false : Promise.reject(err))
   
   ## 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 -->
   
   The above example code rejects with `err` as:
       {
           message: 'error happened in your connection',
           scope: 'socket',
           errid: 'request'
       }
   
   ## Possible Solution
   <!--- Not obligatory, but suggest a fix/reason for the bug, -->
   <!--- or ideas how to implement the addition or change -->
   
   The following change to the config object corrects the issue, as a workaround:
       const {db} = require('nano')({
           url: 'http://some-db.server.com:5984/',
           parseUrl: false,
           requestDefaults: {
               validateStatus: status => status < 500 // Resolve only if the status code is less than 500
           }
       })
   
   ## 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.  Ensure `missing_db` does not exist
   2.  Execute the example code
   3.  
   4.
   
   ## 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 -->
   
   It is necessary to be able to know if a database exists or not
   
   ## Your Environment
   <!--- Include as many relevant details about the environment you experienced the bug in -->
   * Version used:  nano 9.0.5
   * Browser Name and version:
   * Operating System and version (desktop or mobile): node on MacOS
   * Link to your project:
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org