fix(transport): replace Tauri listen() to avoid unlisten race crashing on WKWebView
Call plugin:event|listen/unlisten directly and guard the client-side listener registry cleanup, so unsubscribe always reaches the backend even when the registration eval has not yet populated window.__TAURI_EVENT_LISTENERS__. Prevents the intermittent `listeners[eventId].handlerId` TypeError and the resulting leaked listener.
This commit is contained in:
@@ -2042,11 +2042,7 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
|
||||
})
|
||||
.then((fn) => {
|
||||
if (cancelled) {
|
||||
try {
|
||||
fn()
|
||||
} catch {
|
||||
// Tauri listener may not be fully registered yet
|
||||
}
|
||||
fn()
|
||||
} else {
|
||||
unlisten = fn
|
||||
listenerReadyRef.current = true
|
||||
@@ -2066,11 +2062,7 @@ export function AcpConnectionsProvider({ children }: { children: ReactNode }) {
|
||||
clearTimeout(flushTimerRef.current)
|
||||
flushTimerRef.current = null
|
||||
}
|
||||
try {
|
||||
unlisten?.()
|
||||
} catch {
|
||||
// Tauri listener may not be fully registered yet
|
||||
}
|
||||
unlisten?.()
|
||||
}
|
||||
}, [bufferUnmappedEvent, handleMappedEvent, resolveListenerReadyWaiters])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user