{"record":{"id":"0798e5f89bb9e3ce","repo":"ruvnet/RuView","slug":"no-active-stream-connection-to-reconnect","errorCode":null,"errorMessage":"No active stream connection to reconnect","messagePattern":"No active stream connection to reconnect","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"ui/services/pose.service.js","lineNumber":707,"sourceCode":"        lastUpdate: this.performanceMetrics.lastUpdateTime,\n        messageCount: this.performanceMetrics.messageCount,\n        errorCount: this.performanceMetrics.errorCount,\n        apiHealthy: !!stats\n      };\n    } catch (error) {\n      return {\n        healthy: false,\n        error: error.message,\n        connectionState: this.connectionState,\n        lastUpdate: this.performanceMetrics.lastUpdateTime\n      };\n    }\n  }\n\n  // Force reconnection\n  async reconnectStream() {\n    if (!this.streamConnection) {\n      throw new Error('No active stream connection to reconnect');\n    }\n\n    this.logger.info('Forcing stream reconnection');\n    \n    // Get current connection stats to preserve options\n    const stats = wsService.getConnectionStats(this.streamConnection);\n    if (!stats) {\n      throw new Error('Cannot get connection stats for reconnection');\n    }\n\n    // Extract original options from URL parameters\n    const url = new URL(stats.url);\n    const params = Object.fromEntries(url.searchParams);\n    \n    const options = {\n      zoneIds: params.zone_ids ? params.zone_ids.split(',') : undefined,\n      minConfidence: params.min_confidence ? parseFloat(params.min_confidence) : undefined,\n      maxFps: params.max_fps ? parseInt(params.max_fps) : undefined,","sourceCodeStart":689,"sourceCodeEnd":725,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/ui/services/pose.service.js#L689-L725","documentation":"poseService.reconnectStream() only works when this.streamConnection is set — i.e. a stream was previously started via startPoseStream() and has not been stopped. stopPoseStream() nulls the handle, and a never-started service also has it null, so calling reconnect() in either state throws this Error immediately.","triggerScenarios":"Calling reconnectStream() after stopPoseStream(); calling it from a retry loop when the original startPoseStream() itself failed; a UI 'Reconnect' button clicked before any stream ever started.","commonSituations":"Auto-reconnect logic that runs on page load or after connection-death handlers without checking whether a connection ever existed; button state not bound to connection state.","solutions":["Guard the call and fall back to a fresh start: if (!poseService.streamConnection) return poseService.startPoseStream(lastOptions);","Bind the Reconnect button's disabled state to the connection-state monitor so it is only clickable while a connection exists.","In retry logic, treat this Error as 'nothing to reconnect' and route to startPoseStream with the saved options."],"exampleFix":"// before\nasync function onReconnect() { await poseService.reconnectStream(); }\n// after\nasync function onReconnect() {\n  if (!poseService.streamConnection) return poseService.startPoseStream(lastStreamOptions);\n  await poseService.reconnectStream();\n}","handlingStrategy":"validation","validationCode":"if (!poseService.streamConnection) {\n  // nothing to reconnect — start fresh with the last known options\n  return poseService.startPoseStream(lastStreamOptions ?? {});\n}\nawait poseService.reconnectStream();","typeGuard":"function hasActiveStream(service) {\n  return Boolean(service.streamConnection);\n}","tryCatchPattern":"try {\n  await poseService.reconnectStream();\n} catch (e) {\n  if (e instanceof Error && e.message === 'No active stream connection to reconnect') {\n    return poseService.startPoseStream(lastStreamOptions ?? {});\n  }\n  throw e;\n}","preventionTips":["Check streamConnection (or connection state) before offering/running reconnect.","Save the options used at startPoseStream so a cold restart is always possible.","Do not call reconnect in load/init paths — only from a user-triggered reconnect action on a live connection."],"tags":["state","websocket","pose-stream","ui","precondition"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}