You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm wondering if there's a small bug around this code.
When the if statement matches, an attempt is made to update the user before passing it along to done. However, the call to done immediately after the if statement will likely always resolve before the update to the user completes.
This probably wouldn't affect some applications, because the update call is getting instantiated. But the middleware is likely moving onto to the next middleware a little earlier than expected.
Another consequence of this is that done will get called twice, which I'm pretty sure goes against the contract of how done is intended to be used.
I'm thinking it should instead be:
if(!user.facebook.token){user.facebook.token=token;user.facebook.name=profile.name.givenName+' '+profile.name.familyName;user.facebook.email=profile.emails[0].value;user.save(function(err){if(err)throwerr;returndone(null,user);});}else{returndone(null,user);// user found, return that user}
This issue likely affects the other services' code, too. What do you think?
The text was updated successfully, but these errors were encountered:
Hi there – awesome project!
I'm wondering if there's a small bug around this code.
When the
if
statement matches, an attempt is made to update the user before passing it along todone
. However, the call todone
immediately after theif
statement will likely always resolve before the update to the user completes.This probably wouldn't affect some applications, because the update call is getting instantiated. But the middleware is likely moving onto to the next middleware a little earlier than expected.
Another consequence of this is that
done
will get called twice, which I'm pretty sure goes against the contract of howdone
is intended to be used.I'm thinking it should instead be:
This issue likely affects the other services' code, too. What do you think?
The text was updated successfully, but these errors were encountered: