fix(native-messaging): suppress "Native host has exited" console error
CI / Build & Test (push) Successful in 2m44s
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user