From 9ad160aefcf05fc6ca60d7f2ad5f6d03ea0336f6 Mon Sep 17 00:00:00 2001 From: dianaKhortiuk-frontegg Date: Wed, 22 Jul 2026 14:06:15 +0300 Subject: [PATCH] fix(capacitor): don't hard-kill the app on load() config errors (FR-25948) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit load() terminated the process on missing/invalid config — iOS called exit(1), Android threw RuntimeException — instead of surfacing a recoverable error. Both now log the misconfiguration and return early (abort initialization) rather than killing the app; subsequent JS calls surface the error instead of a crash. --- .../java/com/frontegg/ionic/FronteggNativePlugin.java | 9 +++++++-- ios/Plugin/FronteggNativePlugin.swift | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/android/src/main/java/com/frontegg/ionic/FronteggNativePlugin.java b/android/src/main/java/com/frontegg/ionic/FronteggNativePlugin.java index 97ffcc0..ff732f9 100644 --- a/android/src/main/java/com/frontegg/ionic/FronteggNativePlugin.java +++ b/android/src/main/java/com/frontegg/ionic/FronteggNativePlugin.java @@ -84,7 +84,10 @@ public void load() { } } catch (JSONException e) { - throw new RuntimeException(e); + // FR-25948: don't throw — a RuntimeException here hard-kills the app on a config error. + // Log and abort initialization; JS calls surface the error instead of a crash. + Log.e("FronteggNative", "Failed to parse Frontegg regions config", e); + return; } Class mainActivityClass = resolveMainActivityClass(); @@ -114,7 +117,9 @@ public void load() { } if (baseUrl == null || clientId == null) { - throw new RuntimeException("Missing required config parameters: baseUrl, clientId"); + // FR-25948: don't throw — log and abort initialization instead of crashing the app. + Log.e("FronteggNative", "Missing required config parameters: baseUrl, clientId"); + return; } if (baseUrl.startsWith("https://")) { baseUrl = baseUrl.substring(baseUrl.indexOf("://") + 3); diff --git a/ios/Plugin/FronteggNativePlugin.swift b/ios/Plugin/FronteggNativePlugin.swift index a8c71c8..daecaca 100644 --- a/ios/Plugin/FronteggNativePlugin.swift +++ b/ios/Plugin/FronteggNativePlugin.swift @@ -49,8 +49,10 @@ public class FronteggNativePlugin: CAPPlugin { } if(regions.isEmpty){ + // FR-25948: don't exit(1) — hard-killing the app on misconfiguration is worse than + // leaving the plugin uninitialized. Log and return; JS calls surface the error. print("Frontegg Error: Missing regions configurations") - exit(1) + return } fronteggApp.manualInitRegions(regions: regions, handleLoginWithSocialLogin: handleLoginWithSocialLogin, @@ -76,8 +78,9 @@ public class FronteggNativePlugin: CAPPlugin { handleLoginWithSocialLogin: handleLoginWithSocialLogin, handleLoginWithSSO: handleLoginWithSSO) }else { + // FR-25948: don't exit(1) — log and return instead of terminating the process. print("Frontegg Error: Missing baseUrl or clientId in project configurations") - exit(1) + return } }