From 88b294364f7b478bd595942835d97c23efee1884 Mon Sep 17 00:00:00 2001 From: Dan Xin Date: Fri, 12 Jun 2026 02:05:25 +0800 Subject: [PATCH] gh-9540: duplicated bookmarks on macOS window reopen (gh-14113) Signed-off-by: Dan Xin --- src/zen/common/modules/ZenStartup.mjs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/zen/common/modules/ZenStartup.mjs b/src/zen/common/modules/ZenStartup.mjs index 93e549f56..307fa0dbf 100644 --- a/src/zen/common/modules/ZenStartup.mjs +++ b/src/zen/common/modules/ZenStartup.mjs @@ -100,7 +100,16 @@ class ZenStartup { delete this.promiseInitializedResolve; setTimeout(() => { - gZenWorkspaces._invalidateBookmarkContainers(); + // Wait for the natural PlacesToolbar rebuild before invalidating, so + // the two async rebuilds don't interleave and duplicate bookmarks. + // promiseRebuilt() returns undefined when no rebuild is in flight. + const rebuilt = + document + .getElementById("PlacesToolbar") + ?._placesView?.promiseRebuilt() ?? Promise.resolve(); + rebuilt + .catch(console.error) + .then(() => gZenWorkspaces._invalidateBookmarkContainers()); }); }); }