chore: fix sync FS calls in async functions and add debug logging#622
Merged
Conversation
- Replace existsSync() with fs.promises.access() in scheduler.js runNow() - Replace existsSync() with fs.promises.access() in cron.js findSkillScript() - Add logger.debug() to TUI streaming callback catch block Fixes #621
Owner
Author
PR Audit ResultsChange:
|
| Goal | Status | Notes |
|---|---|---|
Replace existsSync() in scheduler.js async runNow() |
✅ Complete | Replaced with fs.promises.access() + constants.F_OK |
Replace existsSync() in cron.js async findSkillScript() |
✅ Complete | Replaced with fs.promises.access() + constants.F_OK |
| Add debug logging to TUI streaming callback | ✅ Complete | Added logger.debug() in catch block at line 779 |
2. Spec Compliance
The implementation matches the spec requirements:
- REQ-1: No sync FS in async functions — ✅ Both locations fixed
- REQ-2: Error observability in streaming callbacks — ✅ Debug logging added
- REQ-3: Backward compatibility — ✅ No API changes, all tests pass
3. Task Completion
All tasks in tasks.md are marked complete:
- scheduler.js fix
- cron.js fix
- TUI debug logging
- Tests pass (1043/1043)
- Lint passes (0 warnings, 0 errors)
- Coverage maintained (87.40%)
4. Quality Check
Files changed: 9 files (3 source, 5 OpenSpec archive, 1 coverage)
Source changes:
src/scheduler/scheduler.js— ReplacedexistsSync()withaccess()in async contextsrc/tools/cron.js— ReplacedexistsSync()withaccess()in async contextsrc/tui/app.js— Added debug logging to streaming callback catch
No issues found:
- No blocking I/O in async contexts
- No silent catch blocks
- No API changes
- All tests pass
- Lint clean
- Coverage maintained
5. OpenSpec Compliance
- ✅ Proposal created and archived
- ✅ Design document created
- ✅ Spec file created with delta requirements
- ✅ Tasks tracked and completed
- ✅ Archive created at
openspec/changes/archive/2026-07-25-fix-sync-fs-in-async-functions/
Conclusion
This PR successfully addresses all findings from issue #621. The implementation is clean, well-tested, and follows all project conventions. Ready to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Replace synchronous file system calls (existsSync) in async functions with promise-based equivalents (fs.promises.access) to prevent event loop blocking. Add debug-level logging to the TUI streaming callback catch block for improved observability.
Type of Change
Testing
All existing tests pass (1043 tests, 0 failures). No new tests required — this is a behavioral-preserving refactor.
Coverage
Checklist
npm run lintpassesRelated
Fixes #621