refactor(backup): convert sync fs operations to async promises#237
refactor(backup): convert sync fs operations to async promises#237BillChirico merged 4 commits intomainfrom
Conversation
Addresses TODO in backup.js to switch from sync fs operations to fs.promises for better performance and non-blocking I/O. - Convert getBackupDir, createBackup, parseBackupMeta to async - Replace existsSync/mkdirSync with access/mkdir promises - Replace writeFileSync/statSync with async equivalents
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| Filename | Overview |
|---|---|
| src/modules/backup.js | Converted all sync fs operations to node:fs/promises with proper await usage throughout |
| src/api/routes/backup.js | Added async/await to all route handlers that call async backup functions |
Last reviewed commit: 5db6669
There was a problem hiding this comment.
Pull request overview
This PR refactors the backup subsystem to use async node:fs/promises APIs and updates the backup HTTP routes to await the backup module operations, aiming to avoid blocking the event loop during filesystem work.
Changes:
- Reworks
src/modules/backup.jsto use async filesystem operations for backup create/read/list/prune and config import/restore. - Adds/updates
src/api/routes/backup.jsto useasync/awaitfor backup endpoints. - Introduces scheduled-backup helpers (
startScheduledBackups/stopScheduledBackups) in the backup module.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
src/modules/backup.js |
Async backup module implementation (create/list/read/restore/prune + scheduler). |
src/api/routes/backup.js |
Backup API endpoints wired to the async module functions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Greptile review found that setInterval callback was not awaiting the async createBackup() and pruneBackups() calls, which would cause unhandled promise rejections instead of being caught by the try/catch block.
Summary
Converts
src/modules/backup.jsfrom synchronous file system operations to async fs.promises for better performance and non-blocking I/O.Changes
src/modules/backup.js
getBackupDir()to async usingaccess()andmkdir()createBackup()to async usingwriteFile()andstat()parseBackupMeta()to async usingstat()listBackups()to asyncreadBackup()to asyncpruneBackups()to asyncsrc/api/routes/backup.js
async/awaitto all route handlers that call backup functionsVerification
Closes code quality improvement from CODE_IMPROVEMENTS.md analysis