fix: migrate cron module to async API and merge duplicate imports - #668
Merged
Conversation
The callback-based readdir and readFile from node:fs don't auto-promisify in Node 25 — await readdir() throws ERR_INVALID_ARG_TYPE. Switched to node:fs/promises so the async method works correctly. Also changed the reflection-daily command from hardcoded /app to process.cwd() so it resolves correctly regardless of launch directory.
avoidwork
force-pushed
the
fix/cron-reflection-path
branch
from
August 1, 2026 18:17
a1479ab to
0b6445c
Compare
Switched _ensureReflectionJob from sync to async, using node:fs/promises for readdir, mkdir, readFile, and writeFile. This eliminates blocking I/O in the scheduler module.
All filesystem and shell operations in the scheduler module are now non-blocking. Converted isAvailable, _readCrontab, _writeCrontab, add, remove, install, uninstall, list, and sync to async. Updated all callers in tools/cron.js and test files.
Switched _ensureReflectionJob from sync to async, using node:fs/promises for readdir, mkdir, readFile, and writeFile. This eliminates blocking I/O in the scheduler module. Also refactored Cron to accept a mock exec via setExecOverride() so tests can isolate from the system crontab without actually modifying it.
avoidwork
enabled auto-merge (squash)
August 1, 2026 21:30
Merged
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
Migrated the cron module from synchronous to asynchronous execution — replaced
execSyncwith promisifiedexecfromnode:child_process/promisesand all syncfscalls withfs/promisesvariants. Also replaced the hardcoded/apppath in the reflection job withprocess.cwd(). Additionally merged duplicate import statements across multiple TUI panels and the shutdown module, and added theno-duplicate-importslint rule.Type of Change
Testing
tests/unit/scheduler/cron.test.jswith async-compatible mock exec that intercepts crontab commands via callback-based mock, falling through to realexecfor other commands.tests/unit/scheduler.test.jsthat relied onexecSyncand direct sync method calls.tests/unit/tools_cron.test.jstoawaitasync Cron methods.npm run lintpasses with no errors.Coverage
Checklist
npm run lintpassesexecSync)