Skip to content

Conversation

@karishka1222
Copy link

Fix race condition when counting files (fixes #375)

Problem description

While running the eoc compile command, the following error could occur:
Error: ENOENT: no such file or directory, stat '.eoc/classes/EOorg/EOeolang/EOnan$EOtimes.class'

This happened due to a race condition: one process deleted a file while another was trying to get its stats using fs.statSync in the count function.

What was done

  • Added error handling to the count function in src/mvnw.js. Now, if a file or directory is deleted during traversal, it is skipped and the counting continues.
  • Added a test to ensure the function is robust to file deletion during counting.

Why it matters

Now the file counting function works correctly even when files are being changed in parallel, preventing crashes and making the tool more reliable.

Related issue #375

@0crat
Copy link

0crat commented Jun 29, 2025

@karishka1222 Hey team! 🚀 Let's align our branch naming conventions for better project management. Instead of "fix-race-condition-count-files", consider using the ticket number (e.g., "575") as the branch name. This approach helps us track progress more efficiently. While we've deducted 12 points this time, we're confident you'll nail it in the future! Keep up the great work! 💪

@karishka1222
Copy link
Author

@yegor256 Hello, can you check this pull request, please

@yegor256
Copy link
Member

yegor256 commented Jul 7, 2025

@karishka1222 Thanks for your contribution, we appreciate it! Before we can merge this pull request, we need to see all CI workflows pass without errors. We can't merge the pull request into the master branch unless all workflows are green. Try to fix them, also paying attention to code style issues.

@karishka1222
Copy link
Author

@yegor256 Hello! I've fixed pipeline

});
});
it('handles race condition when files are deleted during counting', (done) => {
// Create a temporary directory for testing
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karishka1222 we don't appreciate comments inside method bodies and we don't use blank lines inside methods. You can use this prompt: https://github.com/yegor256/prompt

@karishka1222
Copy link
Author

@yegor256 I fixed the code based on your comment.

@yegor256
Copy link
Member

@maxonfjvipon could you please check this one

@karishka1222
Copy link
Author

@maxonfjvipon check, please

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.

race condition error, while counting files

3 participants