From f8ecfd3b92c44739bce3e8cdc6b065b45f9698d9 Mon Sep 17 00:00:00 2001 From: Dave Page Date: Wed, 10 Jun 2026 15:15:13 +0100 Subject: [PATCH] Fix runtime menu refresh crash when menus not yet received (#9762) refreshMenus() rebuilt the application menu from the module-level cachedMenus, which is only populated once the renderer sends its menu definition via the 'setMenus' IPC. When a menu refresh was triggered before that happened - e.g. an auto-update event, or the user closing the window while the UI was still loading - cachedMenus was undefined and bindMenuClicks() crashed with 'Cannot read properties of undefined (reading map)', surfacing as an uncaught-exception dialog. Guard refreshMenus() so it bails out when there are no cached menus to rebuild. Closes #9762 --- docs/en_US/release_notes_9_16.rst | 1 + runtime/src/js/menu.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/docs/en_US/release_notes_9_16.rst b/docs/en_US/release_notes_9_16.rst index 4f0740cdff0..140b52e078f 100644 --- a/docs/en_US/release_notes_9_16.rst +++ b/docs/en_US/release_notes_9_16.rst @@ -42,6 +42,7 @@ Bug fixes | `Issue #6308 `_ - Fix the infinite loading spinner after an idle database connection is silently dropped, by detecting stale connections and offering a reconnect dialog. | `Issue #9595 `_ - Fix missing ALTER ... SET DEFAULT statements for inherited columns in the generated table SQL/EDIT script. | `Issue #9677 `_ - Fix the Unlogged table toggle in table properties not generating any ALTER TABLE ... SET LOGGED/UNLOGGED statement. + | `Issue #9762 `_ - Fix the "Cannot read properties of undefined (reading 'map')" crash in the desktop runtime when a menu refresh is triggered before the application menus have been received. | `Issue #9828 `_ - Fix tool calls failing against OpenAI-compatible providers that emit empty/null name, arguments, or id fields in streaming continuation deltas. | `Issue #9875 `_ - Fixed an issue where EXPLAIN and EXPLAIN ANALYZE failed to execute when blank lines separated clauses in the SQL query. | `Issue #9810 `_ - Use the ServerManager's passfile for the credential gate in connect() so the check matches the passfile actually used for the connection, and warn on conflicting passfile/passexec settings. diff --git a/runtime/src/js/menu.js b/runtime/src/js/menu.js index a671bcbb8c1..7ba64706a33 100644 --- a/runtime/src/js/menu.js +++ b/runtime/src/js/menu.js @@ -190,6 +190,12 @@ function buildAndSetMenus(menus, pgAdminMainScreen, configStore, callbacks={}) { } export function refreshMenus(pgAdminMainScreen, configStore, callbacks={}) { + // cachedMenus is only populated once the renderer sends its menu definition + // via the 'setMenus' IPC. A refresh can be triggered before that happens + // (e.g. an auto-update event, or the window being closed while the UI is + // still loading). In that case there are no menus to rebuild, so bail out + // to avoid dereferencing an undefined menu list. + if (!cachedMenus) return; buildAndSetMenus(cachedMenus, pgAdminMainScreen, configStore, callbacks); }