Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/client-typescript/tests/RocketRideClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('RocketRideClient Integration Tests', () => {
afterEach(async () => {
if (client.isConnected()) {
// Use a bounded timeout so teardown never hangs the suite
await Promise.race([client.disconnect(), new Promise<void>((resolve) => setTimeout(resolve, 10000))]);
await Promise.race([client.disconnect(), new Promise<void>((_, reject) => setTimeout(() => reject(new Error('disconnect timeout exceeded')), 10000))]);
}
Comment on lines +74 to 75
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.

});

Expand Down Expand Up @@ -1669,7 +1669,7 @@ Line 3: random data ${Math.random().toString(36).substring(2)}`;
}
})
),
new Promise<void>((resolve) => setTimeout(resolve, 15000)),
new Promise<void>((_, reject) => setTimeout(() => reject(new Error('pipeline cleanup timeout exceeded')), 15000)),
]);
pipelineTokens = [];
});
Expand Down Expand Up @@ -2042,7 +2042,7 @@ Line 3: random data ${Math.random().toString(36).substring(2)}`;
expect(uniqueTexts.size).toBe(SENDS_PER_CLIENT * 2);
} finally {
if (clientB.isConnected()) {
await Promise.race([clientB.disconnect(), new Promise<void>((resolve) => setTimeout(resolve, 10000))]);
await Promise.race([clientB.disconnect(), new Promise<void>((_, reject) => setTimeout(() => reject(new Error('disconnect timeout exceeded')), 10000))]);
}
}
},
Expand Down
Loading