fix: replace sync fs calls in async contexts and silent catch blocks - #684
Open
avoidwork wants to merge 6 commits into
Open
fix: replace sync fs calls in async contexts and silent catch blocks#684avoidwork wants to merge 6 commits into
avoidwork wants to merge 6 commits into
Conversation
- Convert src/memory/context.js, reader.js, writer.js, profile.js, prompts.js, retention.js to async fs/promises
- Convert src/skills/discoverer.js, registry.js to async fs/promises
- Convert src/session/loader.js to async fs/promises
- Convert src/sandbox/runner.js detectShebang to async fs/promises
- Convert src/agent/agents/*.js (9 files) to async fs/promises
- Convert src/scheduler/scheduler.js, cron.js to async fs/promises
- Update all callers of converted functions (deepAgents, scheduler, tui/app, tools, session/onboarding)
- Replace all bare catch {} blocks with logger.debug() calls across 39 files
- No hardcoded secrets, eval(), SQL injection vectors, or wildcard exports found
- No console.log() in production code
- context.test.js: await loadContext() calls (12 tests) - profile.test.js: await loadProfile/saveProfile/hasProfile calls, use readFile instead of readFileSync - prompts.test.js: await loadSystemPrompt() calls (5 tests) - discoverer.test.js: await discoverSkills/detectInterpreter/detectShebang calls (28 tests) - onboarding.test.js: await ob.save() calls (2 tests) - agentDefinitions.test.js: add before() hook to wait for async prompt loading All 1054 tests passing.
- Archive OpenSpec change to openspec/changes/archive/2026-08-03-replace-sync-fs-calls-and-silent-catches/ - Create async-fs spec (async fs operations in async contexts) - Create error-logging spec (structured error logging with logger)
… in non-async - Rename all unused catch parameters from 'err' to '_err' (40+ locations) - Remove unused 'logger' imports from 10 files (common.js, loader.js, loadAgents.js, registry.js, sampling.js, clarify.js, web.js, memory.js, compact_context.js, statusBar.js) - Remove unused 'access'/'constants' imports from profile.test.js - Merge duplicate 'node:fs/promises' imports in registry.js - Make processOnboardingInput() async in tui/app.js to support await onboarding.save()
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 all synchronous fs operations (readFileSync, writeFileSync, readdirSync, existsSync, statSync, mkdirSync, unlinkSync) in async contexts with their async equivalents from node:fs/promises. Also replace all bare catch {} blocks with structured error logging using the project logger.
This change affects 56 files across src/ and tests/ — converting 15+ source modules and 8 test files to use async fs operations, and adding proper error logging to 30+ silent catch blocks.
Type of Change
Testing
Coverage
Checklist