Skip to content

Commit

Permalink
Emit token expiry event 1s earlier
Browse files Browse the repository at this point in the history
This allows re-request st2 token in advance, instead of trying to get it when it's _already_ expired.
Add here HTTP request/response time to communicate token update and it leads to issues and races like StackStorm/st2#4119 StackStorm/hubot-stackstorm#178 (comment) StackStorm/hubot-stackstorm#157
  • Loading branch information
armab authored Jun 20, 2019
1 parent 46562a2 commit 8773fd3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ module.exports = function (opts) {
}
this._expiryTimeout = setTimeout(function () {
this.emit('expiry', token);
}.bind(this), new Date(token.expiry) - new Date());
}.bind(this), new Date(token.expiry) - new Date() - 1000);
return token;
}.bind(this));
}
Expand Down

0 comments on commit 8773fd3

Please sign in to comment.