Skip to content

fix: test(client-typescript) disconnect timeout guard should reject instead of resolve#1002

Open
aryaMehta26 wants to merge 1 commit into
rocketride-org:developfrom
aryaMehta26:fix/disconnect-timeout-guard-968
Open

fix: test(client-typescript) disconnect timeout guard should reject instead of resolve#1002
aryaMehta26 wants to merge 1 commit into
rocketride-org:developfrom
aryaMehta26:fix/disconnect-timeout-guard-968

Conversation

@aryaMehta26
Copy link
Copy Markdown

@aryaMehta26 aryaMehta26 commented May 27, 2026

Fixes #968

The previous implementation of the disconnect timeout guard in the TypeScript client tests used resolve() instead of reject() when the timeout was reached. This meant that if client.disconnect() hung, the test would silently pass instead of failing as intended.

This commit updates the timeout promises to use reject() with an appropriate error message, ensuring that test failures on disconnect are properly caught and reported.

Summary by CodeRabbit

  • Tests
    • Enhanced integration test teardown procedures with stricter timeout enforcement to improve test stability and reliability across concurrent operations.

Review Change Stack

The previous implementation used resolve() inside setTimeout(), which silently passed the test if client.disconnect() took longer than the timeout. Switched it to reject() with an error message so tests properly fail on timeout.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR modifies timeout guards in the RocketRideClient integration test suite to enforce stricter teardown behavior. Three Promise.race timeout branches are changed from resolving to rejecting, causing test failures when client disconnection or pipeline cleanup operations exceed their time limits instead of silently timing out.

Changes

Teardown Timeout Enforcement

Layer / File(s) Summary
Strict timeout enforcement for disconnects
packages/client-typescript/tests/RocketRideClient.test.ts
Global afterEach teardown, concurrent pipeline cleanup, and two-client test cleanup each now race against timeout promises that reject (rather than resolve) after 10–15 seconds, ensuring test failures when disconnect or termination operations hang.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Three timeouts now stand guard with care,
No silent passes through the air!
When teardowns lag beyond their time,
They'll fail—a bell that loudly chimes.
Test cleanup strict, no hangs allowed,
The rabbit hops about quite proud! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR addresses the core requirement from issue #968 by changing Promise.race timeout branches to reject, though only one of two required files is modified. Apply the timeout rejection change to packages/client-typescript/tests/deploy.test.ts as specified in issue #968, not just RocketRideClient.test.ts.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: converting timeout promises from resolve to reject in disconnect timeout guards.
Out of Scope Changes check ✅ Passed The changes are narrowly scoped to timeout promise behavior in test teardown, directly addressing the issue without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

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

@github-actions
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/client-typescript/tests/RocketRideClient.test.ts`:
- Around line 74-75: The timeout guard Promises used inside Promise.race (e.g.,
new Promise((_, reject) => setTimeout(() => reject(new Error('disconnect timeout
exceeded')), 10000))) create orphaned timers; update the teardown code in
RocketRideClient.test.ts to capture the setTimeout handle, expose a small helper
(e.g., makeTimeoutRejector or withTimeoutGuard) that returns {promise, clear} or
returns a promise plus the timer id, and then in the finally block call
clearTimeout on the captured handle so timers are cleared when
client.disconnect() or pipeline cleanup finishes early; also include the timeout
duration and context (e.g., "disconnect timeout 10000ms") in the rejection Error
messages to aid debugging.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6cf63480-dc4d-4a74-95ea-6b2fd03d7ed4

📥 Commits

Reviewing files that changed from the base of the PR and between a57a379 and 6c96ee6.

📒 Files selected for processing (1)
  • packages/client-typescript/tests/RocketRideClient.test.ts

Comment on lines +74 to 75
await Promise.race([client.disconnect(), new Promise<void>((_, reject) => setTimeout(() => reject(new Error('disconnect timeout exceeded')), 10000))]);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify timeout races that reject via setTimeout but do not clear timer handles.
rg -n -C3 "Promise\.race\(\[.*setTimeout\(\(\)\s*=>\s*reject" packages/client-typescript/tests/RocketRideClient.test.ts
rg -n -C2 "clearTimeout\(" packages/client-typescript/tests/RocketRideClient.test.ts

Repository: rocketride-org/rocketride-server

Length of output: 703


🏁 Script executed:

#!/bin/bash
# Find all timeout guards related to disconnect/cleanup in this test file
rg -n "disconnect timeout exceeded|pipeline cleanup timeout exceeded" packages/client-typescript/tests/RocketRideClient.test.ts

# Find other Promise.race + setTimeout reject patterns
rg -n -C3 "Promise\.race\(\[.*setTimeout\(" packages/client-typescript/tests/RocketRideClient.test.ts

# Check for any clearTimeout usage in this file
rg -n "clearTimeout\(" packages/client-typescript/tests/RocketRideClient.test.ts

Repository: rocketride-org/rocketride-server

Length of output: 1149


🏁 Script executed:

#!/bin/bash
# Find all timeout guards related to disconnect/cleanup in this test file
rg -n "disconnect timeout exceeded|pipeline cleanup timeout exceeded" packages/client-typescript/tests/RocketRideClient.test.ts

# Find other Promise.race + setTimeout reject patterns
rg -n -C3 "Promise\.race\(\[.*setTimeout\(" packages/client-typescript/tests/RocketRideClient.test.ts

# Check for any clearTimeout usage in this file
rg -n "clearTimeout\(" packages/client-typescript/tests/RocketRideClient.test.ts

Repository: rocketride-org/rocketride-server

Length of output: 1149


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="packages/client-typescript/tests/RocketRideClient.test.ts"

# Show full blocks around each reported line
sed -n '55,90p' "$FILE"
echo "----"
sed -n '1650,1695p' "$FILE"
echo "----"
sed -n '2025,2065p' "$FILE"

# Specifically confirm whether this file uses clearTimeout anywhere
echo "----"
rg -n "clearTimeout\(" "$FILE" || true

Repository: rocketride-org/rocketride-server

Length of output: 3738


Clear orphaned setTimeout timers used as timeout guards in teardown Promise.races (74, ~1672, 2045).

The timeout Promises created inside each Promise.race use setTimeout(...reject...) but never clear/capture the timer handle when disconnect() / pipeline cleanup finishes early; there’s also no clearTimeout( usage in this file. This can leave pending timers and cause late rejections. Capture the timeout handle and clearTimeout it in finally (via a small helper), and include the timeout duration/context in the error messages.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/client-typescript/tests/RocketRideClient.test.ts` around lines 74 -
75, The timeout guard Promises used inside Promise.race (e.g., new Promise((_,
reject) => setTimeout(() => reject(new Error('disconnect timeout exceeded')),
10000))) create orphaned timers; update the teardown code in
RocketRideClient.test.ts to capture the setTimeout handle, expose a small helper
(e.g., makeTimeoutRejector or withTimeoutGuard) that returns {promise, clear} or
returns a promise plus the timer id, and then in the finally block call
clearTimeout on the captured handle so timers are cleared when
client.disconnect() or pipeline cleanup finishes early; also include the timeout
duration and context (e.g., "disconnect timeout 10000ms") in the rejection Error
messages to aid debugging.

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.

test(client-typescript): disconnect timeout guard should reject instead of resolve

1 participant