Fix Firefox native messaging: separate manifests and expose disconnect reason
CI / Build & Test (push) Successful in 3m9s

- Firefox rejects native messaging manifest if allowed_origins is present.
  Install script now writes Chrome-only manifest (allowed_origins) and
  Firefox-only manifest (allowed_extensions) to their respective locations.
- Fix local Firefox manifest by removing allowed_origins.
- Log disconnect reason from port.error (Firefox) in addition to
  runtime.lastError (Chrome) so native messaging failures are visible.
- Log getState failures on disconnect for easier debugging.
This commit is contained in:
Raven Scott
2026-03-03 03:08:53 -05:00
parent ef3bb470c4
commit 39e65b2e9c
4 changed files with 31 additions and 13 deletions
+5 -7
View File
@@ -128,7 +128,7 @@ function connect() {
applyPAC();
}
})
.catch(() => applyPAC());
.catch((err) => { log('getState failed:', err.message); applyPAC(); });
} catch (e) {
log('connectNative failed:', e);
debugLog('connect: failed', e.message, e.stack);
@@ -219,12 +219,10 @@ function connect() {
}
});
port.onDisconnect.addListener(() => {
// 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);
port.onDisconnect.addListener((p) => {
const reason = p?.error?.message || browser.runtime.lastError?.message || null;
if (reason) {
log('onDisconnect reason:', reason);
}
log('Native host disconnected');
extensionState.hostConnected = false;
Binary file not shown.
Binary file not shown.
+26 -6
View File
@@ -164,35 +164,55 @@ curl -fsSL "${RELEASE_BASE}/${EXT_XPI}" -o "${DOWNLOADS}/${EXT_XPI}" 2>/dev/null
# ── Native messaging manifest ──────────────────────────────────────────────────
echo "Installing native messaging manifest..."
MANIFEST=$(cat <<JSON
MANIFEST_CHROME=$(cat <<JSON
{
"name": "com.holesail.browser",
"description": "Holesail Browser native host",
"path": "${HOST_BIN}",
"type": "stdio",
"allowed_origins": ["chrome-extension://fmcenppcipeikpnpopolicnllljclmmi/"]
}
JSON
)
MANIFEST_FIREFOX=$(cat <<JSON
{
"name": "com.holesail.browser",
"description": "Holesail Browser native host",
"path": "${HOST_BIN}",
"type": "stdio",
"allowed_origins": ["chrome-extension://fmcenppcipeikpnpopolicnllljclmmi/"],
"allowed_extensions": ["[email protected]"]
}
JSON
)
if [[ "$PLATFORM" == "darwin" ]]; then
DIRS=(
CHROME_DIRS=(
"$HOME/Library/Application Support/Google/Chrome/NativeMessagingHosts"
"$HOME/Library/Application Support/Chromium/NativeMessagingHosts"
)
FIREFOX_DIRS=(
"$HOME/Library/Application Support/Mozilla/NativeMessagingHosts"
)
else
DIRS=(
CHROME_DIRS=(
"$HOME/.config/google-chrome/NativeMessagingHosts"
"$HOME/.config/chromium/NativeMessagingHosts"
)
FIREFOX_DIRS=(
"$HOME/.mozilla/native-messaging-hosts"
)
fi
for dir in "${DIRS[@]}"; do
for dir in "${CHROME_DIRS[@]}"; do
mkdir -p "$dir"
echo "$MANIFEST" > "${dir}/${MANIFEST_NAME}.json"
echo "$MANIFEST_CHROME" > "${dir}/${MANIFEST_NAME}.json"
echo " Wrote: ${dir}/${MANIFEST_NAME}.json"
done
for dir in "${FIREFOX_DIRS[@]}"; do
mkdir -p "$dir"
echo "$MANIFEST_FIREFOX" > "${dir}/${MANIFEST_NAME}.json"
echo " Wrote: ${dir}/${MANIFEST_NAME}.json"
done