fix(native-messaging): suppress "Native host has exited" console error
CI / Build & Test (push) Successful in 2m44s

Read runtime.lastError in the onDisconnect callback so Chrome does not
log "Unchecked runtime.lastError: Native host has exited" to the
extensions console. The disconnect reason is forwarded to debugLog so
it remains visible when Debug Mode is enabled.
This commit is contained in:
Raven Scott
2026-03-01 02:42:06 -05:00
parent e665a814d7
commit cbc663cacb
+6 -1
View File
@@ -220,7 +220,12 @@ function connect() {
});
port.onDisconnect.addListener(() => {
debugLog('onDisconnect');
// Reading lastError suppresses the "Unchecked runtime.lastError: Native host has exited"
// console error that Chrome logs when the host process exits unexpectedly.
const disconnectReason = browser.runtime.lastError?.message || null;
if (disconnectReason) {
debugLog('onDisconnect reason:', disconnectReason);
}
log('Native host disconnected');
extensionState.hostConnected = false;
activeConnections.clear();