Skip to content

Commit

Permalink
transports, api: use new timer methods
Browse files Browse the repository at this point in the history
transports should call success / failure.
api should call cancel
  • Loading branch information
esatterwhite committed Sep 5, 2017
1 parent 76cbf1e commit 55c0adb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/server/api/delete_timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = {
]
, handler: (req, res, node, cb) => {
const id = req.$.params.timer_id;
req.$.timers.remove(id, (err) => {
req.$.timers.cancel(id, (err) => {
if( err ) {
switch(err.code) {
case 'ENOENT':
Expand Down
8 changes: 4 additions & 4 deletions lib/transports/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ module.exports = function httpTransport( method, url, payload, id, cache ) {
if( method_exp.test(method) && typeof request[_method] !== 'function' ) {
const t = cache.get(id);
t && clearTimeout(t.timer);
cache.remove(id);
cache.failure(id, err);
debug('unable to execute http transport', method, id);
return;
}
Expand All @@ -48,17 +48,17 @@ module.exports = function httpTransport( method, url, payload, id, cache ) {
request[_method](url, options, (err, res, body) => {
if(err){
debug('timer err', err);
return cache.remove(id);
return cache.failure(id, err);
}
if(res.statusCode > 299 ){
debug('timer fail', res.statusCode, body);
const er = new Error(STATUS_CODES[res.statusCode]);
er.code = res.statusCode = res.statusCode;
console.error(er, body);
return cache.remove(id);
return cache.failure(id, err);
}

debug('timer sucess');
return cache.remove(id);
return cache.success(id);
});
};

0 comments on commit 55c0adb

Please sign in to comment.