From: Shannon Sterz <s.sterz@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 6/6] ui: top nav bar: use an abort guard for loading the version
Date: Thu, 27 Nov 2025 16:36:09 +0100 [thread overview]
Message-ID: <20251127153609.440415-8-s.sterz@proxmox.com> (raw)
In-Reply-To: <20251127153609.440415-1-s.sterz@proxmox.com>
so that the request gets aborted when the component is destroyed. this
avoids a potential race condition between this request and a potential
log in.
Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
---
ui/src/top_nav_bar.rs | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ui/src/top_nav_bar.rs b/ui/src/top_nav_bar.rs
index 7e2af71..aa6d6cb 100644
--- a/ui/src/top_nav_bar.rs
+++ b/ui/src/top_nav_bar.rs
@@ -7,6 +7,7 @@ use wasm_bindgen::UnwrapThrowExt;
use pwt::prelude::*;
use pwt::widget::menu::{Menu, MenuButton, MenuEntry, MenuEvent, MenuItem};
+use pwt::AsyncAbortGuard;
use yew::html::{IntoEventCallback, IntoPropValue};
use yew::virtual_dom::{VComp, VNode};
@@ -74,6 +75,7 @@ pub struct PdmTopNavBar {
dark_mode: bool,
version_info: Option<VersionInfo>,
view_state: Option<ViewState>,
+ abort_guard: Option<AsyncAbortGuard>,
}
impl Component for PdmTopNavBar {
@@ -95,6 +97,7 @@ impl Component for PdmTopNavBar {
dark_mode,
version_info: None,
view_state: None,
+ abort_guard: None,
}
}
@@ -121,8 +124,10 @@ impl Component for PdmTopNavBar {
true
}
Msg::Load => {
- ctx.link()
- .send_future(async move { Msg::LoadResult(load_version().await) });
+ let link = ctx.link().clone();
+ self.abort_guard.replace(AsyncAbortGuard::spawn(async move {
+ link.send_message(Msg::LoadResult(load_version().await))
+ }));
true
}
Msg::LoadResult(result) => {
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-11-27 15:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 15:36 [pdm-devel] [PATCH datacenter-manager/yew-widget-toolkit 0/7] avoid more race conditions on log in Shannon Sterz
2025-11-27 15:36 ` [pdm-devel] [PATCH yew-widget-toolkit 1/1] loader: add helper to allow aborting a load Shannon Sterz
2025-11-27 18:22 ` [pdm-devel] applied: " Thomas Lamprecht
2025-11-27 15:36 ` [pdm-devel] [PATCH datacenter-manager 1/6] ui: main: abort running task load on log out Shannon Sterz
2025-11-27 15:36 ` [pdm-devel] [PATCH datacenter-manager 2/6] ui: main: move requests into an async pool and drop it on logout Shannon Sterz
2025-11-27 15:36 ` [pdm-devel] [PATCH datacenter-manager 3/6] ui: main: only render acl context when we are logged in Shannon Sterz
2025-11-27 15:36 ` [pdm-devel] [PATCH datacenter-manager 4/6] ui: resource tree: use an async pool for requests Shannon Sterz
2025-11-27 15:36 ` [pdm-devel] [PATCH datacenter-manager 5/6] ui: node status: handle the request via an AsyncAbortGuard Shannon Sterz
2025-11-27 15:36 ` Shannon Sterz [this message]
2025-11-27 20:54 ` [pdm-devel] applied: [PATCH datacenter-manager/yew-widget-toolkit 0/7] avoid more race conditions on log in Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251127153609.440415-8-s.sterz@proxmox.com \
--to=s.sterz@proxmox.com \
--cc=pdm-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox