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
2 changes: 1 addition & 1 deletion app/composables/useConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const useConnector = createSharedComposable(function useConnector() {
const response = await $fetch<ConnectResponse>(`http://127.0.0.1:${port}/connect`, {
method: 'POST',
body: { token },
timeout: 5000,
timeout: 30000,
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

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.

})
Comment on lines 115 to 119

if (response.success && response.data) {
Expand Down
Loading