Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug when using multiple accounts simultaneously #33

Open
mkaguilera opened this issue Sep 20, 2019 · 0 comments
Open

bug when using multiple accounts simultaneously #33

mkaguilera opened this issue Sep 20, 2019 · 0 comments

Comments

@mkaguilera
Copy link

When using multiple accounts simultaneously, the code to refresh the token fails for one of the accounts. The symptom is that request.post() never invokes the callback because it waits forever for the token. I did some debugging and what happens is that the TokenRequest remains in the "pending" state forever. That happens because the authenticate() callback updates the TokenRequest of the other account. I suspect the problem is that "this" and "self" in TokenRequest.prototype.get() refer to different objects. Here's my debugging session:

debug> s
break in node_modules/google-oauth-jwt/lib/token-cache.js:30
28 this._cache[key] = new TokenRequest(this.authenticate, options);
29 }

30 this._cache[key].get(callback);
31 };
32
debug> s
break in node_modules/google-oauth-jwt/lib/token-cache.js:70
68 TokenRequest.prototype.get = function (callback) {
69
70 if (this.status == 'expired') {
71
72 this.status = 'pending';
debug> repl
Press Ctrl + C to leave debug repl
this
{ status: 'expired',
pendingCallbacks: Array(2),
issued: 1568844683750,
duration: 3600000,
token: '[ONE TOKEN]' }
self
{ status: 'completed',
pendingCallbacks: Array(0),
issued: 1568883615083,
duration: 3600000,
token: '[OTHER TOKEN]' }

You can see that "this" and "self" refer to different objects. Subsequently, when authenticate() finishes and invokes the callback, the callback updates the "self" TokenRequest, but the real outstanding TokenRequest (this) remains pending forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant