Skip to content

fix(testmanagement): enforce a hard timeout on TCG generation polling - #413

Open
SavioBS629 wants to merge 1 commit into
browserstack:mainfrom
SavioBS629:security/pmaa-300-tcg-poll-timeout
Open

fix(testmanagement): enforce a hard timeout on TCG generation polling#413
SavioBS629 wants to merge 1 commit into
browserstack:mainfrom
SavioBS629:security/pmaa-300-tcg-poll-timeout

Conversation

@SavioBS629

Copy link
Copy Markdown
Collaborator

Problem

The two TCG test-generation polling loops in src/tools/testmanagement-utils/TCG-utils/api.ts had no wall-clock bound:

  • pollTestCaseDetails ran while (!done) and only exited when a "termination" message arrived.
  • pollScenariosTestDetails ran a setInterval that was only cleared on termination, a non-200 status, or a thrown error.

If the backend never emits a terminal message — a stuck job, a dropped message, or details streamed without a terminal event — either loop polls indefinitely (~every 10s) and keeps every awaiting caller alive forever. pollTestCaseDetails is fanned out per test-case batch and Promise.alled, so a single stuck trace hangs the whole result.

Fix

  • Add shared bounds TCG_POLL_MAX_WAIT_MS (10 min) and TCG_POLL_INTERVAL_MS to TCG-utils/config.ts.
  • Enforce a hard wall-clock deadline in both loops (a deadline check in the while loop; a companion setTimeout that clears the interval and rejects), mirroring the bounded polling pattern already used in poll-lca-status.ts.
  • Add regression tests for the timeout and the normal-termination paths.

Testing

  • npm run lint, tsc --noEmit, and the new tests/tools/tcg-poll-timeout.test.ts pass.
  • Pre-existing unrelated flakes in tfaRcaCollaboration.test.ts are present on main and untouched by this change.

🤖 Generated with Claude Code

The two TCG test-generation polling loops in TCG-utils/api.ts had no
wall-clock bound:

- pollTestCaseDetails ran `while (!done)` and only exited on a
  "termination" message.
- pollScenariosTestDetails ran a setInterval that was only cleared on
  termination, a non-200 status, or a thrown error.

If the backend never emits a terminal message (stuck job, dropped
message, or details streamed without a terminal event), either loop
polls forever and keeps every awaiting caller alive indefinitely.

Add a shared TCG_POLL_MAX_WAIT_MS (10 min) and TCG_POLL_INTERVAL_MS to
TCG-utils/config.ts and enforce a hard deadline in both loops, mirroring
the bounded pattern already used in poll-lca-status.ts. Add regression
tests covering the timeout and the normal-termination paths.

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

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited), Workspace UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 9f9b8c8a-9027-4842-bf6c-4015a12bfcba

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

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