#8616·capacitor

[Bug]: Plugin call after navigation can be answered before reply proxy is updated

Author: MateStrysewskeCreated Sep 21, 2026Updated Sep 21, 2026
Labelstriage

Capacitor Version

@capacitor/cli: 8.4.0 @capacitor/core: 8.4.0 @capacitor/android: 8.4.0

Other API Details

bash
npm: 11.0.0
node: 22.13.0

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

After a reload or navigation, a fast plugin call (e.g. a Preferences read, which is how the bug appeared for us) can potentially never resolve as it uses the previous proxy instead of the updated one. The cause are these lines in MessageHandler.java:

if (isMainFrame) {
    postMessage(message.getData());
    javaScriptReplyProxy = replyProxy;
}

In case of a fast plugin call, sendResponseMessage() is reached before the proxy is updated, and therefore still uses the previous proxy and is silently dropped. Later calls work, and there's also no issue upon first page load as, at this point, javaScriptReplyProxy is null and the old evaluateJavascript path is used instead.

Expected Behavior

All plugin calls of the new page should go through the updated proxy.

Project Reproduction

Reproduced in a private repo

Additional Information

The bug is avoidable with android.useLegacyBridge = true as this routes every response through evaluateJavascriptand avoids the proxy entirely.

I've locally fixed the bug by swapping the two lines above, i.e., making sure the proxy is updated before the message post.