Priority: MEDIUM
Description
PR #292 adds basic test for stop() during initialization, but several critical edge cases remain untested. These edge cases were identified during code review and represent real race conditions that could occur in production.
Missing Test Scenarios
High Priority
- Multiple stop() calls during initialization - Verify idempotency
- stop() racing with timeout - Verify timeout is cleared
- stop() racing with error event - Verify no double-rejection
- Concurrent start() during stop() - Verify no server orphaning
Medium Priority
- 'initialized' event firing after stop() - Verify handler doesn't set started=true
- Error event firing after stop() clears listeners - Verify defensive handling
- Rapid start/stop/start cycles - Stress test for state consistency
Example Test Structure
describe('edge cases', () => {
it('should handle multiple stop() calls during initialization', async () => {
const startPromise = transport.start()
await Promise.all([
transport.stop(),
transport.stop(),
transport.stop()
])
await expect(startPromise).rejects.toThrow()
})
it('should clear timeout when stop() interrupts initialization', async () => {
jest.useFakeTimers()
const startPromise = transport.start()
await transport.stop()
jest.advanceTimersByTime(11000)
// Verify no additional cleanup or errors occurred
})
})
Benefits
- Catches regression bugs
- Documents expected behavior in edge cases
- Validates all code paths are reachable and correct
- Improves confidence in concurrent operation safety
Related
Priority: MEDIUM
Description
PR #292 adds basic test for stop() during initialization, but several critical edge cases remain untested. These edge cases were identified during code review and represent real race conditions that could occur in production.
Missing Test Scenarios
High Priority
Medium Priority
Example Test Structure
Benefits
Related