@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Fixed
11+ - ** Critical: Document translation infinite loop risk** - Added timeout and max attempts to prevent infinite polling
12+ - Added ` MAX_POLL_ATTEMPTS ` (180 attempts) and ` TOTAL_TIMEOUT_MS ` (90 minutes) constants
13+ - Polling now terminates after 180 attempts or 90 minutes total time
14+ - Prevents CLI from hanging indefinitely if DeepL API status doesn't update
15+ - Clear error messages indicate timeout exceeded and suggest document may still be processing
16+ - ** Impact** : Previously, misbehaving API responses could cause infinite loops
17+ - Location: ` src/services/document-translation.ts:136-191 `
18+
19+ - ** Critical: Cache service memory leak** - Fixed duplicate event handler registration
20+ - Added ` handlersRegistered ` flag to prevent registering exit handlers multiple times
21+ - Now uses ` process.once() ` instead of ` process.on() ` for cleanup handlers
22+ - Prevents memory leak when ` getInstance() ` called multiple times in tests or long-running processes
23+ - ** Impact** : Previously, each ` getInstance() ` call added new event handlers to process
24+ - Location: ` src/storage/cache.ts:62-89 `
25+
26+ - ** High Priority: Type safety violations** - Fixed 2 linter errors
27+ - Fixed unsafe array assignment in ` translateBatch() ` using explicit type constructor
28+ - Fixed Promise-in-setTimeout warning by properly wrapping async callback
29+ - ** Impact** : Improved type safety and eliminated compiler warnings
30+ - Locations: ` src/services/translation.ts:163 ` , ` src/services/watch.ts:156-178 `
31+
32+ - ** Logging Consistency** - Replaced console.warn with Logger.warn in DeepL client
33+ - Replaced direct ` console.warn() ` with ` Logger.warn() ` for proxy URL warnings
34+ - Ensures all logging respects quiet mode (` --quiet ` flag)
35+ - Maintains consistent logging patterns across entire codebase
36+ - ** Impact** : Previously, proxy warnings would bypass quiet mode
37+ - Location: ` src/api/deepl-client.ts:177 `
38+
1039### Added
1140- ** XML Tag Validation** - Comprehensive validation for XML tag handling options
1241 - Validates ` --splitting-tags ` , ` --non-splitting-tags ` , and ` --ignore-tags ` parameters
@@ -47,6 +76,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4776 - ** Impact** : Previously, translation errors in watch mode could be silently ignored
4877 - Location: ` src/services/watch.ts:156-170 `
4978
79+ - ** Critical: Watch service race condition on stop** - Fixed race condition in file translation
80+ - Debounced translation timers could fire after watch service was stopped
81+ - Added guard check to prevent translations from running after ` stop() ` is called
82+ - Prevents "Cannot read property of null" errors when translations execute after cleanup
83+ - ** Impact** : Previously, stopping watch mode could cause unhandled errors from pending translations
84+ - Location: ` src/services/watch.ts ` debounce timer callback
85+
5086- ** Critical: Race condition in document translation polling** - Fixed concurrent execution bug
5187 - AbortSignal cleanup and timeout completion could execute simultaneously
5288 - Added ` isSettled ` flag to ensure only one path (resolve or reject) executes
@@ -55,12 +91,82 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5591 - Race occurred when: timeout fires at same moment as abort signal
5692 - Location: ` src/services/document-translation.ts:195-224 `
5793
58- - ** Critical: Silent data loss in batch translation** - Added user warning for failures
59- - Batch translations could silently filter out failed translations without notification
60- - Now logs warning when some translations fail: "⚠️ Warning: N of M translations failed silently"
61- - Helps users identify incomplete batch operations instead of assuming success
62- - ** Impact** : Previously, users wouldn't know if 3 out of 10 translations failed
63- - Location: ` src/services/translation.ts:225-230 `
94+ - ** Critical: Batch translation failure handling** - Improved error propagation and user feedback
95+ - Fixed batch translation to properly track failures and warn users about partial failures
96+ - When all batches fail, now throws error instead of returning empty array
97+ - When some batches fail, logs warning: "⚠️ Warning: N of M translations failed"
98+ - Helps users identify incomplete batch operations and propagates errors correctly
99+ - ** Impact** : Previously, all-failure case returned empty array; partial failures were silent
100+ - Location: ` src/services/translation.ts:199-260 `
101+
102+ - ** High Priority: Resource leaks in cache service** - Implemented proper disposal pattern
103+ - CacheService singleton now automatically closes database on process exit
104+ - Added handlers for ` exit ` , ` SIGINT ` , and ` SIGTERM ` signals
105+ - Prevents "database is locked" errors and ensures clean shutdowns
106+ - Added ` isClosed ` flag to prevent double-close errors
107+ - ** Impact** : Previously, process termination could leave database connections open
108+ - Location: ` src/storage/cache.ts ` singleton getInstance()
109+
110+ - ** High Priority: Non-cryptographic random in security context** - Replaced with crypto.randomBytes
111+ - Variable placeholder generation now uses ` crypto.randomBytes() ` instead of ` Math.random() `
112+ - Uses cryptographically secure random bytes with SHA-256 hashing
113+ - Eliminates collision risk in high-volume translation scenarios
114+ - ** Impact** : Previously, ` Math.random() ` could produce collisions in variable placeholders
115+ - Location: ` src/services/translation.ts:369-381 ` preserveVariables()
116+
117+ - ** High Priority: Silent proxy URL errors** - Added validation warnings
118+ - Invalid proxy URLs now log warning instead of silently failing
119+ - Helps users identify proxy configuration issues early
120+ - Warning: "⚠️ Warning: Invalid proxy URL: [ url] . Proxy will not be used."
121+ - ** Impact** : Previously, invalid proxy URLs caused silent failures in HTTP requests
122+ - Location: ` src/api/deepl-client.ts:174-176 `
123+
124+ - ** Performance: Concurrency validation** - Added bounds checking
125+ - BatchTranslationService now validates concurrency is between 1-100
126+ - Prevents invalid concurrency values that could cause performance issues
127+ - Throws descriptive error for out-of-bounds values
128+ - ** Impact** : Previously, invalid concurrency values could cause unexpected behavior
129+ - Location: ` src/services/batch-translation.ts ` constructor
130+
131+ - ** Performance: Unnecessary array copy in getSupportedFileTypes** - Optimized to return readonly reference
132+ - Changed return type from copied array to ` readonly string[] `
133+ - Eliminates unnecessary memory allocation on every call
134+ - TypeScript enforces immutability at compile time
135+ - ** Impact** : Reduces memory allocations for frequently called method
136+ - Location: ` src/services/file-translation.ts:35-37 `
137+
138+ - ** Logic Bug: File size null handling** - Fixed error handling for missing files
139+ - ` getFileSize() ` now correctly handles case when file doesn't exist
140+ - Returns ` null ` instead of throwing, allowing caller to handle gracefully
141+ - Improved error message: "File not found or cannot be accessed: [ path] "
142+ - ** Impact** : Previously, missing files could cause unclear errors
143+ - Location: ` src/cli/commands/translate.ts:167-175 `
144+
145+ - ** Code Smell: Redundant null check in watch service** - Removed unnecessary check
146+ - Removed redundant null check after non-null assertion operator
147+ - Code already used ` ! ` operator, making additional check unreachable
148+ - ** Impact** : Cleaner code, no behavior change
149+ - Location: ` src/services/watch.ts:208-210 `
150+
151+ - ** Code Smell: Deprecated _ batchOptions parameter** - Removed unused parameter
152+ - Removed deprecated ` _batchOptions ` parameter from ` translateBatch() ` method signature
153+ - Parameter was never used and cluttered the API
154+ - ** Impact** : Cleaner API surface, no behavior change
155+ - Location: ` src/services/translation.ts:139-142 `
156+
157+ - ** UX: Poor API error messages** - Added context to error messages
158+ - API errors now include request details for easier debugging
159+ - Example: "Translation count mismatch: sent 2 texts but received 1 translations. Target language: es"
160+ - Example: "No translation returned from DeepL API. Request: translate text (150 chars) to de"
161+ - ** Impact** : Users can now understand what went wrong without inspecting code
162+ - Location: ` src/api/deepl-client.ts ` translate() and translateBatch()
163+
164+ - ** UX: Cache disabled logging** - Added informative logging
165+ - Now logs when cache is disabled globally: "ℹ️ Cache is disabled"
166+ - Now logs when cache is bypassed per-request: "ℹ️ Cache bypassed for this request (--no-cache)"
167+ - Helps users understand why translations aren't being cached
168+ - ** Impact** : Users no longer confused about caching behavior
169+ - Location: ` src/services/translation.ts:88-92 `
64170
65171## [ 0.7.0] - 2025-10-16
66172
0 commit comments