Description
In sync-leaderboard.js, student history updates are handled sequentially using blocking synchronous operations (fs.readFileSync, fs.writeFileSync, etc.) inside a forEach loop. As the student registry grows, this causes two critical flaws:
- The Freeze (Event Loop Starvation): Processing hundreds of files one-by-one synchronously blocks Node.js's single thread completely. The script freezes, and the server becomes entirely unresponsive to other operations or web requests.
- The Crash (
EMFILE Error): If fixed naively using a standard Promise.all(), Node.js will try to open all hundreds of files at the exact same microsecond. This hits operating system file descriptor limits, causing an immediate crash and leaving files corrupted.
Expected Behavior
Files should be processed asynchronously in controlled batches (e.g., 20 at a time) to prevent both freezing the server thread and hitting operating system file limits.
Steps to Reproduce
- Populate a database/mock file with over 300 entries.
- Run the synchronization task.
- Observe severe execution lag/freezing during the file update phase, or an immediate
EMFILE crash if uncontrolled parallel execution is applied.
IPlease assign this issue to me!
Description
In
sync-leaderboard.js, student history updates are handled sequentially using blocking synchronous operations (fs.readFileSync,fs.writeFileSync, etc.) inside aforEachloop. As the student registry grows, this causes two critical flaws:EMFILEError): If fixed naively using a standardPromise.all(), Node.js will try to open all hundreds of files at the exact same microsecond. This hits operating system file descriptor limits, causing an immediate crash and leaving files corrupted.Expected Behavior
Files should be processed asynchronously in controlled batches (e.g., 20 at a time) to prevent both freezing the server thread and hitting operating system file limits.
Steps to Reproduce
EMFILEcrash if uncontrolled parallel execution is applied.IPlease assign this issue to me!