node-oauth2-provider icon indicating copy to clipboard operation
node-oauth2-provider copied to clipboard

ensure save emits are executed before we return to the user

Open jsullivanlive opened this issue 11 years ago • 1 comments

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.

jsullivanlive avatar Nov 06 '13 01:11 jsullivanlive

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 :)

ammmir avatar Nov 06 '13 05:11 ammmir