mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Fixes race condition in `setupInjectedToolTest`. To reproduce add short sleep to AsyncRecorder.RecordToolUsage method (inside newly spawned go-routine): https://github.com/coder/coder/blob/46821525f7d2f7466735463898fb6e054c169f85/aibridge/recorder/recorder.go#L254-L258 Upstream request counter can reach 2 while no recording has been done since asyncRecorder does it asynchronously: https://github.com/coder/coder/blob/46821525f7d2f7466735463898fb6e054c169f85/aibridge/internal/integrationtest/setupbridge.go#L242-L244 Added consuming request to `setupInjectedToolTest` so `newInterceptionProcessor` handler finishes before returning from `setupInjectedToolTest` which guarantees that all recordings are done: https://github.com/coder/coder/blob/46821525f7d2f7466735463898fb6e054c169f85/aibridge/bridge.go#L282 Fixes: https://github.com/coder/internal/issues/1526