fix(ws): assign websocket after onConnected succeeds (#7639)

* feat(layout): add logging of MihomoWebSocket instances in dev mode

* refactor(hooks): defer ws assignment in use-mihomo-ws-subscription

* chore: update tauri-plugin-mihomo-api dependency source to use github protocol

* docs: update changelog with websocket connection fix
This commit is contained in:
oomeow
2026-07-30 15:33:45 +00:00
committed by GitHub
parent 10dbe60671
commit 4b3bc54b2d
6 changed files with 42 additions and 24 deletions
+8 -10
View File
@@ -97,17 +97,11 @@ const createSharedSubscriptionEntry = (
return
}
entry.ws = ws
syncSharedWsRefs(entry)
clearReconnectTimer()
const owner = pickActiveOwner(entry)
if (owner?.onConnected) {
await owner.onConnected(ws)
if (entry.closed) {
await ws.close()
return
}
await owner?.onConnected?.(ws)
if (entry.closed) {
await ws.close()
return
}
ws.addListener((msg: Message) => {
@@ -117,6 +111,10 @@ const createSharedSubscriptionEntry = (
activeOwner.handleMessage(msg.data)
})
entry.ws = ws
syncSharedWsRefs(entry)
clearReconnectTimer()
} catch (ignoreError) {
if (!entry.closed && !entry.ws) {
clearReconnectTimer()