#8637·capacitor

[Bug]: Android lifecycle events call triggerEvent when the bridge is unavailable

Author: neaveCreated Sep 30, 2026Updated Sep 30, 2026
Labelstriage

Capacitor Version

Installed: @capacitor/core, @capacitor/android, and @capacitor/cli 8.5.2.

Other API Details

Node 22.23.2; npm 10.9.8.

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

Android sometimes logs:

Capacitor/Console: File:  - Line 1 - Msg: Uncaught TypeError: Cannot read properties of undefined (reading 'triggerEvent')

MockCordovaWebViewImpl.triggerDocumentEvent() sends pause/resume events by evaluating window.Capacitor.triggerEvent(...) without checking whether the bridge exists. This call is still unguarded on the default branch.

One likely case is server.errorPath: Android deliberately serves that page without injecting the bridge, but lifecycle events can still be sent to it. The exact trigger for the observed log has not yet been isolated.

Expected Behavior

Skip lifecycle events when the page has no Capacitor bridge. Normal pause/resume events should continue working once the bridge is available.

Project Reproduction

No standalone reproduction repository yet. Suggested minimal setup, based on the source inspection:

  1. Add a plain error.html to the web assets, with no JavaScript.
  2. Set server.errorPath: 'error.html' and android.minWebViewVersion: 500 to force that page on a current WebView.
  3. Run on Android, background the app, then return to it and check Logcat.

These steps have not yet been verified in a fresh project.

Additional Information

Related reports: #2183, #7048 and #7957 describe the same or similar symptoms, but do not establish the same cause. #7458 reports a similar pause-event error on iOS.

The related iOS fix #8595 skips lifecycle events before the page is ready. Could Android also guard event dispatch when the bridge is unavailable? Thanks!