4 Commits

Author SHA1 Message Date
Nathan Wallace
57712dc4df Race on cancelActiveQuery without synchronization closes #4802 (#4844)
* Add test for #4802: cancelActiveQuery should be safe for concurrent access

* Fix #4802: Add mutex protection to cancelActiveQuery
2025-11-16 13:46:48 -05:00
Nathan Wallace
a202100395 ClosePrompt nil check closes #4788 (#4827)
* Add test demonstrating bug #4788 - ClosePrompt panics with nil

Adds TestClosePromptNilCancelPanic that reproduces the bug where
ClosePrompt() panics with a nil pointer dereference when cancelPrompt
is nil. This can happen if ClosePrompt is called before the prompt is
fully initialized.

Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix #4788: Add nil check before calling cancelPrompt

Prevents panic in ClosePrompt() when cancelPrompt is nil.
This can happen if ClosePrompt is called before the prompt
is fully initialized.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 12:38:56 -05:00
Nathan Wallace
cb1fa48173 Fix flaky TestQueryContextLeakage test (#4887)
Changes:
1. Renamed TestQueryContextLeakage -> TestContextCancellationTiming
   - The test was checking cancellation timing, not memory leaks
   - Updated comments to reflect actual purpose

2. Increased timeout from 1ms to 100ms
   - 1ms is too aggressive for CI runners under load
   - 100ms still catches real deadlocks while avoiding flakiness
   - Added detailed comments explaining the timeout choice

3. Added TestNoGoroutineLeaks using goleak
   - Properly tests for actual resource leaks (goroutines)
   - More reliable than memory-based leak detection
   - Uses industry-standard goleak library

The original 1ms timeout caused intermittent CI failures on slower
runners, as context cancellation involves goroutine scheduling that
has no guaranteed sub-millisecond timing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-11-15 08:05:00 -05:00
Nathan Wallace
2e5f3fda97 Add comprehensive passing tests from bug hunting initiative (#4864) 2025-11-13 09:26:46 +08:00