Skip to content

Error Handling ​

Bridge calls fail in predictable ways. Handle these explicitly.

Error types ​

TypeMeaning
BridgeUnavailableErrorNot running in PWAKit native wrapper
BridgeTimeoutErrorCall exceeded timeout (default 30000 ms)
BridgeErrorNative returned an error or send failed

Common failure patterns ​

SymptomLikely causeFix
BridgeUnavailableErrorRunning in normal browserGuard with runtime detection
BridgeTimeoutErrorNative action stalledIncrease timeout and inspect native logs
module not availableFeature flag disabledEnable feature and sync config
Permission-related errorMissing iOS usage key or denied permissionUpdate Info.plist, retry permission flow

Pattern: explicit runtime guard ​

ts
import { getPlatformInfo, ios } from "@pwa-kit/sdk";

export async function authenticateOrThrow() {
  const env = getPlatformInfo();
  if (!env.isNative) {
    throw new Error("PWAKit native runtime required");
  }

  return ios.biometrics.authenticate("Continue");
}

Pattern: custom timeout ​

ts
import { bridge } from "@pwa-kit/sdk";

await bridge.call("healthkit", "queryStepCount", {
  startDate: "2026-03-01T00:00:00Z",
  endDate: "2026-03-02T00:00:00Z"
}, {
  timeout: 45000
});

Debug checklist ​

  1. Confirm native runtime (getPlatformInfo().isNative).
  2. Confirm config feature flag is enabled.
  3. Run npx @pwa-kit/cli sync --validate.
  4. Rebuild and reproduce.
  5. Inspect simulator or device logs.

Released under the MIT License.