You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Delay Handling**: Tests functions with time delays
33
+
34
+
### `resilient-operation.e2e.test.js`
35
+
End-to-end tests for the ResilientOperation class:
36
+
-**Basic Retry Logic**: Tests retry behavior for failed calls
37
+
-**Circuit Breaker**: Tests circuit breaker functionality with failure thresholds
38
+
-**Caching**: Tests result caching and duplicate call avoidance
39
+
-**Preset Configurations**: Tests different preset configurations (fast, reliable)
40
+
41
+
### `test-runner.js`
42
+
A simple test runner utility that:
43
+
- Verifies test file existence
44
+
- Checks Jest installation
45
+
- Validates module imports
46
+
- Provides test coverage summary
47
+
27
48
## Running Tests
28
49
29
50
### Prerequisites
@@ -91,6 +112,28 @@ The tests use Jest mocks for:
91
112
-`setTimeout`/`setInterval` for time-based tests
92
113
- Environment variables for configuration
93
114
115
+
## Known Issues and TODOs
116
+
117
+
### Memory Leak Investigation Needed
118
+
The ResilientOperation class may have potential memory leaks due to ongoing async operations that continue after tests complete. This manifests as "Cannot log after tests are done" warnings.
119
+
120
+
**Current Issues:**
121
+
- setTimeout calls in retry logic that aren't properly cleared
122
+
- AbortController instances that aren't cleaned up
123
+
- Rate limiting token bucket operations that continue running
124
+
- Circuit breaker cooldown timers that persist
125
+
126
+
**Current Workaround:**
127
+
- Tests add delays (`await new Promise(resolve => setTimeout(resolve, 200))`) to allow operations to complete
128
+
- Console.log is mocked to prevent warnings
129
+
130
+
**TODO:**
131
+
- Add a `destroy()` or `cleanup()` method to ResilientOperation
132
+
- Ensure all timers are cleared when operations complete or fail
133
+
- Add proper AbortController cleanup
134
+
- Consider using WeakRef or FinalizationRegistry for automatic cleanup
135
+
- Add memory leak detection in tests
136
+
94
137
## Adding New Tests
95
138
96
139
When adding new tests:
@@ -99,7 +142,8 @@ When adding new tests:
99
142
3. Mock external dependencies appropriately
100
143
4. Test both success and failure scenarios
101
144
5. Include edge cases and error conditions
102
-
6. Update this README if adding new test categories
145
+
6. Add appropriate delays for async operations to complete
146
+
7. Update this README if adding new test categories
0 commit comments