Skip to content

ai tests: the speech in-flight limit check no longer races the 2 second timeout - #3696

Merged
BaseMax merged 1 commit into
mainfrom
fix/ai-voice-crowd-race
Nov 20, 2026
Merged

BaseMax merged 1 commit into
mainfrom
fix/ai-voice-crowd-race

Conversation

@BaseMax

@BaseMax BaseMax commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

On main the AI job failed one api_flow check after the earlier fixes: "the API's own in-flight limit answers 503" got [504,504,504,504,504] (it passed on the run before).

The check started five conversions at once against the hung speech mock with AI_STT_TIMEOUT_SECONDS=2 and 4 slots (STT_SLOTS). If the fifth request reaches stt_enter after the first one has already timed out and left its slot, it finds a free slot and also ends in 504, so the result depends on how fast the runner processes the uploads.

The test now starts four conversions, waits 500 ms so they hold all four slots, then sends the fifth, which has to get the immediate 503 speech_busy. The in-flight check for /me still runs while the four are in flight. Test only.

Summary by CodeRabbit

  • Tests
    • Updated the speech concurrency test to submit the fifth conversion separately and verify the expected busy and timeout responses.

@BaseMax
BaseMax requested a review from a team as a code owner November 20, 2026 00:14
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The speech concurrency test now starts four conversions, waits 500 ms, and submits the fifth. It combines the results before checking the expected counts of speech_busy (503) and timeout (504) responses.

Changes: Speech concurrency test

Layer / File(s) Summary
Stagger conversion requests
ai/backend/tests/api_flow.mjs
The test submits four conversions first and the fifth after 500 ms. It combines their results before checking the existing status-count expectations.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Other

Possibly related PRs

  • SalamLang/Salam#2760: Adds the speech service and in-flight limit behavior that this test exercises.

Suggested reviewers: bdadmehr0

Merge Risk: Low · up to 86120

This only changes a test. The 500 ms delay is a small residual timing assumption that could make the in-flight-limit test less reliable under heavy load. It does not affect product behavior, so the change is mergeable with minor follow-up.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions

Copy link
Copy Markdown
Contributor
sha=861206f9bca1e70ec7022b326d0d284ed435b869

🤖 Salam AI review

Verdict: ✅ Good to merge

commit 861206f · 1 files · +3 −2 · model salam

Summary

This pull request updates the AI API flow test so the speech in-flight limit check no longer depends on request timing. It starts four conversions, waits for them to occupy all slots, then sends the fifth conversion and expects an immediate 503 while the first four time out. The change is test-only and makes the previously flaky assertion deterministic.

What changed

The test in ai/backend/tests/api_flow.mjs now starts only the first four crowd conversions, waits 500 ms so they hold all four STT slots, and then sends the fifth conversion separately. The /me in-flight check still runs while the four conversions are active, and the final assertion expects one speech_busy 503 and four 504 timeouts.

Review

No blocking issues are visible in the diff. The change directly addresses the described race: the fifth request can no longer arrive after an earlier conversion has already timed out and freed a slot. The resulting status counts still match the assertion, and the test remains focused on behavior rather than implementation details.

Tests

This is a test-only change. It adjusts orchestration of existing requests and does not alter production code or add new assertions beyond the existing expected counts.

Risks

The test still relies on timing assumptions, including the 500 ms pause and the configured 2 second STT timeout. If the test environment is unusually slow, the pause may not be long enough to guarantee that all four conversions have entered their slots before the fifth request is sent. That risk is much smaller than the original race, but it remains a timing-based assumption.


⚠️ This review was written automatically by an AI and may contain mistakes. It is a helper for maintainers, not a replacement for a human review: check the code yourself before merging.

@BaseMax
BaseMax merged commit 9a5c133 into main Nov 20, 2026
12 of 13 checks passed
@BaseMax
BaseMax deleted the fix/ai-voice-crowd-race branch November 20, 2026 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant