chore: increase timeout for connection requests to 30 seconds#2684
chore: increase timeout for connection requests to 30 seconds#2684JounQin wants to merge 1 commit intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
📝 WalkthroughWalkthroughThe pull request increases the ChangesConnector Timeout
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Hello! Thank you for opening your first PR to npmx, @JounQin! 🚀 Here’s what will happen next:
|
There was a problem hiding this comment.
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 `@app/composables/useConnector.ts`:
- Line 118: The post-connect state refresh uses a shorter timeout than the
updated connect timeout causing a slow connector to succeed then immediately be
marked disconnected; update refreshState() to use the same 30000ms timeout (or a
shared constant) as the /connect request (the timeout value set where connect is
called) and apply the same error-handling pattern used by connect (catch, log
with context, and preserve expected state) so both connect and refreshState use
a consistent timeout and error behavior.
🪄 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: CHILL
Plan: Pro
Run ID: 01675d77-e96e-4190-844d-04ded3ecddc9
📒 Files selected for processing (1)
app/composables/useConnector.ts
| method: 'POST', | ||
| body: { token }, | ||
| timeout: 5000, | ||
| timeout: 30000, |
There was a problem hiding this comment.
Align post-connect state refresh timeout with the new connect timeout
Line 118 increases /connect to 30s, but refreshState() still uses 5s (Line 183). A slow connector can now connect successfully and then immediately flip to connected = false via the refresh catch path, which undermines this fix.
Proposed fix
+ const CONNECTOR_TIMEOUT_MS = 30000
+
async function connect(token: string, port: number = DEFAULT_PORT): Promise<boolean> {
@@
const response = await $fetch<ConnectResponse>(`http://127.0.0.1:${port}/connect`, {
method: 'POST',
body: { token },
- timeout: 30000,
+ timeout: CONNECTOR_TIMEOUT_MS,
})
@@
async function refreshState(): Promise<void> {
@@
const response = await $fetch<StateResponse>(`${baseUrl.value}/state`, {
headers: {
Authorization: `Bearer ${config.value.token}`,
},
- timeout: 5000,
+ timeout: CONNECTOR_TIMEOUT_MS,
})As per coding guidelines "Use error handling patterns consistently".
🤖 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 `@app/composables/useConnector.ts` at line 118, The post-connect state refresh
uses a shorter timeout than the updated connect timeout causing a slow connector
to succeed then immediately be marked disconnected; update refreshState() to use
the same 30000ms timeout (or a shared constant) as the /connect request (the
timeout value set where connect is called) and apply the same error-handling
pattern used by connect (catch, log with context, and preserve expected state)
so both connect and refreshState use a consistent timeout and error behavior.
There was a problem hiding this comment.
Pull request overview
Adjusts the connector client’s /connect request timeout to reduce false “timeout” failures during local connector startup/handshake, addressing issue #2683.
Changes:
- Increased
/connectrequest timeout from 5s to 30s in the connector composable.
| const response = await $fetch<ConnectResponse>(`http://127.0.0.1:${port}/connect`, { | ||
| method: 'POST', | ||
| body: { token }, | ||
| timeout: 5000, | ||
| timeout: 30000, | ||
| }) |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🔗 Linked issue
close #2683
🧭 Context
5s timeout for connection is tool short
📚 Description