Skip to content

ensure save emits are executed before we return to the user#39

Open
jsullivanlive wants to merge 1 commit intoammmir:masterfrom
jsullivanlive:save-token-before-returning
Open

ensure save emits are executed before we return to the user#39
jsullivanlive wants to merge 1 commit intoammmir:masterfrom
jsullivanlive:save-token-before-returning

Conversation

@jsullivanlive
Copy link

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.

race conditions can happen 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
@ammmir
Copy link
Owner

ammmir commented Nov 6, 2013

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

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

Successfully merging this pull request may close these issues.

2 participants