Skip to content

chore: fix sync FS calls in async functions and add debug logging#622

Merged
avoidwork merged 2 commits into
mainfrom
chore/fix-sync-fs-in-async-functions
Jul 25, 2026
Merged

chore: fix sync FS calls in async functions and add debug logging#622
avoidwork merged 2 commits into
mainfrom
chore/fix-sync-fs-in-async-functions

Conversation

@avoidwork

Copy link
Copy Markdown
Owner

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

  • Bugfix (non-breaking change which fixes an issue)
  • Refactor (no functional changes)

Testing

All existing tests pass (1043 tests, 0 failures). No new tests required — this is a behavioral-preserving refactor.

Coverage

  • Line coverage maintained (87.40%)

Checklist

  • npm run lint passes
  • Tests pass with maintained line coverage
  • No forbidden patterns used
  • Conventional Commit style applied

Related

Fixes #621

- 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
@avoidwork

Copy link
Copy Markdown
Owner Author

PR Audit Results

Change: fix-sync-fs-in-async-functions

PR: #622

Audit Summary

Status: ✅ PASS — All requirements met

1. Goal Fulfillment

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 — Replaced existsSync() with access() in async context
  • src/tools/cron.js — Replaced existsSync() with access() in async context
  • src/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.

@avoidwork
avoidwork merged commit 979ee2a into main Jul 25, 2026
2 checks passed
@avoidwork
avoidwork deleted the chore/fix-sync-fs-in-async-functions branch July 25, 2026 17:13
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.

audit: comprehensive src audit findings

1 participant