sentry-tauri
sentry-tauri copied to clipboard
Plugin causing another instance to launch on macOS
I am using the sentry-tauri plugin and my code follows the example in examples/basic-app. The plugin appears to be working properly during development with no issues, but when running tauri build and opening the resulting binary on macOS, a second instance of the app starts a few seconds after opening the app. I have narrowed the issue down to this plugin--when I comment out the .plugin(sentry_tauri::plugin()) line from the Tauri builder in main() and rebuild, the issue is gone. Any ideas?
Correction: it's actually not commenting the .plugin(sentry_tauri::plugin()) line that fixes it, this one is the only one that needs to be commented:
let _guard = sentry_tauri::minidump::init(&client);
I am using:
sentry-tauri = "0.2"
rust-version = "1.67.1"
tauri = "1.4.1"
tauri-build = "1.4.0"
Running into exactly the same issue. Removing the _guard line fixes the double launch. The plugin is still catching errors and publishing them to sentry. Is there a security or performance impact when removing the guard?
@timfish do you have any insights on this? 😊
Sorry this dropped out of my notifications and got forgotten. I'll take a look!
Minidump support is via sentry-rust-minidump:
sentry_rust_minidump::initstarts the current executable again with an argument that causes it to start in crash reporter mode. In this mode it waits for minidump notification from the main app process and handles writing and sending of the minidump file as an attachment to Sentry.
I guess the extra instance is something to do with that not working correctly.
If I start the app via the internal executable (ie. ./tauri-test-app.app/Contents/MacOS/tauri-test-app) I don't get the duplicate instance so I guess it's something to do with how macOS starts app bundles.
Thanks @timfish! For now I've removed the _guard line and it seems to still publish to sentry, can you comment on the implications of that line being missing?
That line enables minidump support which is for native crashes that are not Rust panics. This will cover crashes caused by non-Rust native code or unsafe Rust that causes segmentation faults.
FYI I had commented out that _guard line and haven't been too worried about it, but today I had an issue in my app that was causing crashes and nothing was getting reported to sentry. I noticed that when I uncommented the _guard line, the crash did get sent to sentry. The crash was caused by a Rust panic. Is this what you would expect? I was under the impression that it would still report but it doesn't seem to.
Update: the reason the Rust panic wasn't getting reported was because I was doing this:
let _ = sentry::init(( ...
instead of this:
let _client = sentry::init(( ...
When I update the variable name to _client the Rust panic is reported, but not the native crash. When I update the variable name to client uncomment the _guard line both the Rust panic and the native crash are reported as two separate events.
Yep one of the few foot-guns with rust that has caught me out a few times. If you name a variable _ it will be dropped immediately!