Skip to content

Commit

Permalink
Clear timer when the operation is finished.
Browse files Browse the repository at this point in the history
  • Loading branch information
noppoMan committed Nov 21, 2016
1 parent 4d18a7f commit b607838
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
22 changes: 14 additions & 8 deletions build/npdynamodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ return /******/ (function(modules) { // webpackBootstrap

module.exports = {
"name": "npdynamodb",
"version": "0.2.9",
"version": "0.2.11",
"description": "A Node.js Simple Query Builder and ORM for AWS DynamoDB.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -925,17 +925,20 @@ return /******/ (function(modules) { // webpackBootstrap
], function(promiseInterface){
QueryBuilder.prototype[promiseInterface] = function(cb){
var self = this;
var gotResponse = false;
var feature = self._feature;
var callbacks = this._callbacks;
var timer;

return Promise.all(callbacksPromisified.bind(self)(callbacks.beforeQuery)).then(function(){
var built = feature.buildQuery();
self.emit('beforeQuery', built.params);

return new Promise(function(resolve, reject){
var request = feature.client[built.method](built.params, function(err, data){
gotResponse = true;
if(timer) {
clearTimeout(timer);
timer = null;
}
if(err) {
return reject(err);
}
Expand All @@ -944,11 +947,9 @@ return /******/ (function(modules) { // webpackBootstrap

// Handle timeout
if(self._options.timeout !== null) {
setTimeout(function(){
if(!gotResponse) {
request.abort();
reject(new Error("The connection has timed out."));
}
timer = setTimeout(function(){
request.abort();
reject(new Error("The connection has timed out."));
}, self._options.timeout || 5000);
}
});
Expand Down Expand Up @@ -991,6 +992,7 @@ return /******/ (function(modules) { // webpackBootstrap
'filterContains',
'filterNotContains',
'limit',
'offset',
'desc',
'asc',
'create',
Expand Down Expand Up @@ -2288,6 +2290,10 @@ return /******/ (function(modules) { // webpackBootstrap
this.nextThen = 'query';
};

Feature.prototype.offset = function(exclusiveStartKey){
this.exclusiveStartKey(exclusiveStartKey);
};

Feature.prototype.whereIn = function(keys, values){
//items[this.conditions.TableName] = {};
if(!_.isArray(keys)) {
Expand Down
Loading

0 comments on commit b607838

Please sign in to comment.