-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Race condition in _pluralizeAliases #928
Comments
Seems like the more robust solution here would be to use some sort of synchronous |
|
When setting the flag immediately, consider the following: If the calling function were to implement some type of try/catch block when calling this method, and some exception were encountered, the calling function would catch it and attempt to recover. If it cared to check, Since there is currently no such error handling structure in place, I guess it comes down to personal preference here, but setting the flag prematurely will definitely add to Ember's technical debt. |
@kogi This method is not very large and is self-contained. I think if we decided to add that, it would be obvious enough. |
https://github.com/emberjs/data/blob/master/packages/ember-data/lib/system/serializer.js#L1107-L1131
I presume the first line of this method:
...is to avoid calling this method more than once. The problem is that the _didPluralizeAliases flag is not set to true until the end of the method. Normally that wouldn't be a problem, but from what I can tell the Ember.assert method executes asynchronously. This creates a race condition where the _pluralizeAliases method can be called again before the _didPluralizeAssets flag is set to true.
Seems the simple fix is to set the flag right after the check:
It looks like there are a few places where this technique is being used and could potentially have the same race conditions.
The text was updated successfully, but these errors were encountered: