Fix Android logcat spam from empty call.resolve()#1123
Fix Android logcat spam from empty call.resolve()#1123mattriese wants to merge 5 commits intogetsentry:mainfrom
Conversation
When Capacitor Android bridge methods resolve with no payload (call.resolve()), the bridge logs "undefined" to Logcat for each call. This creates massive log spam for high-frequency methods like addBreadcrumb (called for every console log). Changes: - addBreadcrumb: resolve with new JSObject() instead of no args - captureEnvelope: resolve with new JSObject() instead of no args - closeNativeSdk: resolve with new JSObject() instead of no args - setExtra: resolve with new JSObject() instead of no args - setTag: resolve with new JSObject() instead of no args - clearBreadcrumbs: add missing call.resolve(new JSObject()) - setUser: add missing call.resolve(new JSObject()) - iOS setContext: add missing call.resolve() for parity Fixes the "Capacitor/Console I File: - Msg: undefined" spam in Logcat when console breadcrumbs are enabled. See: ionic-team/capacitor#4986
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
| # And the CLI then renames it | ||
|
|
||
| # node files | ||
| dist/ |
There was a problem hiding this comment.
Lets keep dist on this list
| @@ -1,11 +1,11 @@ | |||
| { | |||
| "name": "@sentry/capacitor", | |||
| "homepage": "https://github.com/getsentry/sentry-capacitor", | |||
| "homepage": "https://github.com/mattriese/sentry-capacitor", | |||
There was a problem hiding this comment.
Would you be able to undo the changes here?
|
Thank you for this PR! |
| } | ||
| call.resolve(); | ||
| // Resolve with empty object to avoid Capacitor logging "undefined" to Logcat | ||
| // See: https://github.com/ionic-team/capacitor/issues/4986 |
There was a problem hiding this comment.
Is this link correct? it redirects to a PR ionic-team/capacitor#4986
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
📢 Type of change
📜 Description
Wrap all
call.resolve()invocations withJSObject()(e.g.call.resolve(new JSObject())) for plugin methods that return no meaningful data, instead of callingcall.resolve()with no argument.This prevents Android logcat from being flooded with blank/undefined console log entries. When Capacitor's bridge completes a plugin call, it logs the resolved value to logcat. Calling
call.resolve()with no argument causes Capacitor to log"File: - Line 333 - Msg: undefined"(or similar) for every completed call. By passing an emptyJSObjectinstead, the bridge receives a valid serializable value and does not emit these noisy undefined logs.💡 Motivation and Context
This addresses a known Capacitor Android bug: ionic-team/capacitor#8063 — "PluginCall.resolve logs in Logcat inconsistently". When
call.resolve()is invoked with no argument, the Capacitor Console API logsundefinedto logcat for every completed plugin call.The Sentry Capacitor plugin makes many bridge calls, and several methods (especially
addBreadcrumb, which runs for every console log captured as a breadcrumb) resolve with no return value. In apps with frequent logging or breadcrumb activity, this produces significant logcat spam—hundreds of lines like:This obscures real logs and makes Android debugging difficult. The fix is a simple workaround: pass
new JSObject()tocall.resolve()instead of nothing. Capacitor does not log when given a proper object, so the spam is eliminated.Related: ionic-team/capacitor#8063 (closed, fixed in Capacitor core via #8225). This change provides the same workaround for users on older Capacitor versions and ensures clean logcat output regardless.
💚 How did you test it?
I have been using this fork in my app for 2+ months now and it has been working great. I have not noticed any regressions. I forked off of 2.4.1 and just merged in 3.0.0. I will mark this as ready after using the new merged version for a while.
Capacitor/Console I ... Msg: undefined.📝 Checklist
sendDefaultPIIis enabled🔮 Next steps
None. This is a self-contained bugfix.