Fix runtime menu refresh crash when menus not yet received (#9762) (#10070)

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
This commit is contained in:
Dave Page
2026-06-12 15:38:19 +05:30
committed by GitHub
parent ed9bf2f249
commit 4fa95c58af
2 changed files with 7 additions and 0 deletions
+1
View File
@@ -43,6 +43,7 @@ Bug fixes
| `Issue #6308 <https://github.com/pgadmin-org/pgadmin4/issues/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 <https://github.com/pgadmin-org/pgadmin4/issues/9595>`_ - Fix missing ALTER ... SET DEFAULT statements for inherited columns in the generated table SQL/EDIT script.
| `Issue #9677 <https://github.com/pgadmin-org/pgadmin4/issues/9677>`_ - Fix the Unlogged table toggle in table properties not generating any ALTER TABLE ... SET LOGGED/UNLOGGED statement.
| `Issue #9762 <https://github.com/pgadmin-org/pgadmin4/issues/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 <https://github.com/pgadmin-org/pgadmin4/issues/9828>`_ - Fix tool calls failing against OpenAI-compatible providers that emit empty/null name, arguments, or id fields in streaming continuation deltas.
| `Issue #9875 <https://github.com/pgadmin-org/pgadmin4/issues/9875>`_ - Fixed an issue where EXPLAIN and EXPLAIN ANALYZE failed to execute when blank lines separated clauses in the SQL query.
| `Issue #9810 <https://github.com/pgadmin-org/pgadmin4/issues/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.
+6
View File
@@ -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);
}