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/10/02 08:19:56 UTC

[GitHub] j3k0 opened a new issue #124: `then` and `catch` both called

j3k0 opened a new issue #124: `then` and `catch` both called
URL: https://github.com/apache/couchdb-nano/issues/124
 
 
   ## Expected Behavior
   
    * When using promises ;
    * When `db.get` returns 404 (because the document is missing) ;
    * Then I expect **either of** `.then` or `.catch` callback to be called.
   
   ## Current Behavior
   
    * When using promises ;
    * When `db.get` returns 404 (because the document is missing) ;
    * Then **both** `.then` and `.catch` callbacks are called.
   
   ## Steps to Reproduce (for bugs)
   
   
   ```js
   const rnd = Math.random();
   db.get(id)
   .then((body) => console.log({rnd, body}))
   .catch(err) => console.log({rnd, err}));
   ```
   
   Output:
   ```
   {
      rnd: 0.9767401252511854,
      err: { Error: missing
   at Request._callback (/node_modules/nano/lib/nano.js:151:15)
   at Request.self.callback (/node_modules/request/request.js:185:22)
   [...],
   name: 'Error',
   error: 'not_found',
   reason: 'missing',
   scope: 'couch',
   statusCode: 404,
   [...]
      }
   }
   
   {
     rnd: 0.9767401252511854,
     body: undefined
   }
   ```
   
   ## Context
   
   Check if a document is already in the database.
   
   ## Your Environment
   
   Node v10 on Docker (image `node:10`).

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