Coax call timeout - CBLite

Consider a scenario where we need to make multiple request to fetch/update the documents one after another(not in parallel). To achieve that we need to use ES6 Promises. So If we wrap the coax code to fetch/update documents inside an ES6 promise object and make one request after another one is resolved, the 2nd request gets resolved i.e. control never comes back to the promise and after some time a timeout error shows up.

Sample coax call wrapped inside es6 promise
export function asyncTest(documentId){
return new Promise((resolve, reject)=> config.db.get(documentId, (err, data) => {
if (err) {
reject(err);
} else {
resolve(data);
}
}));
}

function sample(){
asyncTest(‘123’); // this request will get the document with id#123
asyncTest(‘456’); // this request will error out with timeout error
}

Inside the above function asyncTest(), if we use any other request api say ‘reqwest‘ (available in npm) the same code works without any error.
Are there any examples to put data/update document using reqwest. we got the reads working but not writes.

Is this any issue with coax?

I would recommend giving the swagger client a try, it has an option to enable promises which is convenient for chaining operations as you’ve described. For a new project, you’re better off using the swagger client instead of coax.

See:

  1. Instructions for using the Swagger client w/ Sync Gateway
  2. Instructions for using the Swagger client w/ Couchbase Lite