Repository navigation
fix(gui-client): don't panic during setup hook - #9112
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR removes the use of Tauri’s built-in setup hook (which panics on errors) and instead spawns a custom async task that waits for RunEvent::Ready before performing initialization steps like tray setup, update checks, and smoke tests.
- Replace
.setuphook with asetup_taskthat awaits aRunEvent::Readyvia a new mpsc channel. - Move update-checker and smoke-test spawns, tray initialization, and controller startup inside the custom setup task.
- Adjust the
app.run_returnloop to send the ready signal and handle exit prevention.
Comments suppressed due to low confidence (2)
rust/gui-client/src-tauri/src/gui.rs:146
- [nitpick] Consider renaming
ready_txandready_rxto more descriptive names likeready_event_txandready_event_rxto clarify their purpose.
let (ready_tx, mut ready_rx) = mpsc::channel::<tauri::AppHandle>(1);
rust/gui-client/src-tauri/src/gui.rs:188
- Since this change introduces a new channel-based readiness mechanism, consider adding a test that simulates
RunEvent::Readyto ensure the setup task proceeds as expected.
// Block until Tauri is ready.
|
|
||
| // Spawn the setup task. | ||
| // Everything we need to do once Tauri is fully initialised goes in here. | ||
| let setup_task = rt.spawn(async move { |
There was a problem hiding this comment.
[nitpick] The setup logic inside this spawned async block is sizable—consider extracting it into a dedicated async function (e.g., run_app_setup) to improve readability and testability.
Member
Author
|
Clients for testing: https://github.com/firezone/firezone/actions/runs/14986910069 |
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As part of launching the Tauri GUI client, we need to observe a specific initialisation order. In particular, we need to wait until Tauri sends us a
RunEvent::Readybefore we can initialise things like the tray menu.To make this more convenient, Tauri offers a so-called "setup hook" that can be set on the app builder. Unfortunately, Tauri internally panics if this provided setup-hook returns an
Err. Removing this is tracked upstream: tauri-apps/tauri#12815.Until this is fixed, we stop using this "setup hook" and instead spawn our own task that performs this work. This task needs to wait until Tauri is ready. To achieve that, we introduce an additional mpsc channel that sends a notification every time we receive a
RunEvent::Ready. That should only happen once. We only read from the receiver once, which is why we ignore the error on the sending side in case the receiver has already been dropped.Resolves: #9101