Skip to content
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

New rule: Disallow assignments that can lead to race conditions due to usage of await or yield (require-atomic-updates) #1314

Open
feross opened this issue Jul 5, 2019 · 2 comments

Comments

@feross
Copy link
Member

feross commented Jul 5, 2019

https://eslint.org/docs/rules/require-atomic-updates

This was surprising to me. Apparently the following code contains a race condition:

let totalLength = 0;

async function addLengthOfSinglePage(pageNum) {
  totalLength += await getPageLength(pageNum);
}

Promise.all([addLengthOfSinglePage(1), addLengthOfSinglePage(2)]).then(() => {
  console.log('The combined length of both pages is', totalLength);
});

Ecosystem impact: Only one repo failed. Looks to be a false positive. Reported here: eslint/eslint#11954 This carries some amount of false positive risk (at least based on what I've seen on the eslint tracker). I'd like to enable this in standard 13 and see how it goes. We can relax this rule if there are too many false positives.

@feross feross added this to the standard v13 milestone Jul 5, 2019
@feross feross changed the title New rules: Disallow assignments that can lead to race conditions due to usage of await or yield (require-atomic-updates) New rule: Disallow assignments that can lead to race conditions due to usage of await or yield (require-atomic-updates) Jul 5, 2019
@feross feross closed this as completed Jul 6, 2019
@Lonniebiz
Copy link

Lonniebiz commented Jul 8, 2019

@feross

Take a look at this false positive:
eslint/eslint#11967

@feross
Copy link
Member Author

feross commented Jul 10, 2019

Given the false positive reported by @Lonniebiz in #1320 and the reports coming in on the ESLint repo here (eslint/eslint#11899) I'm going to disable this rule for the standard 13 release out of an abundance of caution. We can revisit it again later once it's had some more kinks worked out.

Issues to watch:

@feross feross reopened this Jul 10, 2019
@feross feross added blocked and removed accepted labels Jul 10, 2019
@feross feross removed this from the standard v13 milestone Jul 10, 2019
feross added a commit to standard/eslint-config-standard that referenced this issue Jul 10, 2019
brettz9 pushed a commit to brettz9/eslint-config-standard that referenced this issue Dec 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

2 participants