Skip to content

frontend: Fix MAVLink2Rest orphan WebSocket reconnects - #4044

Open
joaoantoniocardoso wants to merge 1 commit into
bluerobotics:masterfrom
joaoantoniocardoso:pr/mavlink2rest-orphan-reconnect
Open

frontend: Fix MAVLink2Rest orphan WebSocket reconnects#4044
joaoantoniocardoso wants to merge 1 commit into
bluerobotics:masterfrom
joaoantoniocardoso:pr/mavlink2rest-orphan-reconnect

Conversation

@joaoantoniocardoso

@joaoantoniocardoso joaoantoniocardoso commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • On intentional close, clear reconnect timeouts and detach onclose so dying sockets cannot resurrect.
  • setBaseUrl closes the previous send socket before opening a new one (probe can call setBaseUrl more than once).

Test plan

  • Load BlueOS, confirm MAVLink heartbeats / params still work
  • Reload / HMR: console should not accumulate reconnecting zombie WS over time
  • Vehicle reconnect after autopilot restart still recovers within a few seconds

Supersedes #4030 (recreated from fork joaoantoniocardoso/BlueOS-docker instead of same-repo head).

@github-actions

Copy link
Copy Markdown

Automated PR Review

0. Summary

  • Verdict: LGTM :shipit:

Fixes orphan WebSocket reconnects in core/frontend/src/libs/MAVLink2Rest/. Both Endpoint and Mavlink2RestManager now track an intentionalClose flag and the pending reconnect setTimeout handle, so intentional closes detach onclose/onmessage, cancel the queued 5 s reconnect, and gate the reconnect branch — preventing the previous behavior where updateUrl()/setBaseUrl() would leave the old socket's onclose alive and reconnecting to the stale URL.

No further comments, nice job 👍

Generated by PR Review Bot. This is advisory, a human reviewer must still approve.

@joaoantoniocardoso joaoantoniocardoso added the move-to-stable Needs to be cherry-picked and move to stable label Jul 27, 2026
@joaoantoniocardoso
joaoantoniocardoso force-pushed the pr/mavlink2rest-orphan-reconnect branch 2 times, most recently from cfb78ac to 3878bb5 Compare July 30, 2026 22:48
@joaoantoniocardoso

Copy link
Copy Markdown
Member Author

Rebased; the image is now available on Docker Hub.

Disable reconnect on intentional close and close the previous send
socket in setBaseUrl so probe/url changes cannot leave zombie sockets.
@joaoantoniocardoso
joaoantoniocardoso force-pushed the pr/mavlink2rest-orphan-reconnect branch from 3878bb5 to a63c25c Compare August 4, 2026 22:33
@patrickelectric

Copy link
Copy Markdown
Member

Can you explain how the original error can be replicated ?

@joaoantoniocardoso

joaoantoniocardoso commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Can you explain how the original error can be replicated ?

Sorry for the lack of context.

This one addresses an extra mavlink2rest WebSocket connection being created for each tracked topic a few seconds after reloading BlueOS, ending up with 1 dead + 2 active ones. The damage is controlled, as it doesn't pile indefinitely.

To see it, open any reasonably quiet page of BlueOS, open the Network tab from the browser's developer tools, filter for connection type WebSocket and for HEARTBEAT (example). Reload the page, wait a few seconds, and inspect each connection by clicking on each of them. You'll see two active ones and one dead. With this patch, we'll only ever have 1 active in the same scenario.

Before:
image

After:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

move-to-stable Needs to be cherry-picked and move to stable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants