node-oauth2-provider
node-oauth2-provider copied to clipboard
ensure save emits are executed before we return to the user
A race condition happens when the user uses this express app to generate a token and then tries to use the access_token before the save transaction was successful with another app. The response to the user was happening for me several milliseconds earlier, leaving enough time for a server to beat the token to the database.
that's true, but we're not passing a callback so calling each individual listener doesn't guarantee anything... unless what you do in the listener is synchronous and you throw an error.
a test would be helpful to understand! i'm not against your fix, i just want to understand how it fixes an inherent design flaw in the code :)