objectionary / eoc

Command-line toolkit for parsing, compiling, transpiling, optimizing, linking, dataizing, and running EOLANG programs
https://www.npmjs.com/package/eolang
MIT License
17 stars 16 forks source link

race condition error, while counting files #375

Open yegor256 opened 2 weeks ago

yegor256 commented 2 weeks ago

I got this error, while running eoc compile:

node:fs:1658
  const stats = binding.stat(
                        ^

Error: ENOENT: no such file or directory, stat '.eoc/classes/EOorg/EOeolang/EOnan$EOtimes.class'
    at Object.statSync (node:fs:1658:25)
    at count (/opt/homebrew/lib/node_modules/eolang/src/mvnw.js:170:16)
    at count (/opt/homebrew/lib/node_modules/eolang/src/mvnw.js:171:18)
    at count (/opt/homebrew/lib/node_modules/eolang/src/mvnw.js:171:18)
    at count (/opt/homebrew/lib/node_modules/eolang/src/mvnw.js:171:18)
    at print (/opt/homebrew/lib/node_modules/eolang/src/mvnw.js:188:45)
    at Timeout.check [as _onTimeout] (/opt/homebrew/lib/node_modules/eolang/src/mvnw.js:140:7)
    at listOnTimeout (node:internal/timers:594:17)
    at process.processTimers (node:internal/timers:529:7) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '.eoc/classes/EOorg/EOeolang/EOnan$EOtimes.class'
}

Node.js v22.8.0

I can't reproduced it though. It seems to be a race condition problem: one "thread" is running mvn, while another "thread" is trying to count files in the directory. At some point of time, one file gets deleted, which leads to runtime error in another thread (which is counting).