Skip to content

[bug] reloading application with custom menu elements results in TypeError: window['_1093741199'] is not a function #13391

@binarytide

Description

@binarytide

Describe the bug

everything works fine on first load, but subsequent refreshes of the application result in

Image

for each custom menu item added

Reproduction

No response

Expected behavior

No response

Full tauri info output

[✔] Environment
    - OS: Mac OS 15.4.1 x86_64 (X64)
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.84.1 (e71f9a9a9 2025-01-27)
    ✔ cargo: 1.84.1 (66221abde 2024-11-19)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 20.18.3
    - pnpm: 10.7.1
    - yarn: 1.22.22
    - npm: 11.1.0
    - deno: deno 2.2.12

[-] Packages
    - tauri 🦀: 2.5.1
    - tauri-build 🦀: 2.2.0
    - wry 🦀: 0.51.2
    - tao 🦀: 0.33.0
    - @tauri-apps/api : 2.5.0
    - @tauri-apps/cli : 2.5.0

[-] Plugins
    - tauri-plugin-dialog 🦀: 2.2.1
    - @tauri-apps/plugin-dialog : 2.2.1
    - tauri-plugin-fs 🦀: 2.2.1
    - @tauri-apps/plugin-fs : 2.2.1
    - tauri-plugin-shell 🦀: 2.2.1
    - @tauri-apps/plugin-shell : 2.2.1

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist/spa
    - devUrl: http://localhost:9000/
    - framework: Vue.js (Quasar)
    - bundler: Vite
✨  Done in 13.76s.

Stack trace


Additional context

our code:

export const initMenu = async () => {
  const dumyMenu = await Submenu.new({
    items: [
      await PredefinedMenuItem.new({
        item: 'Quit',
      }),
    ],
  })
  const fileMenu = await Submenu.new({
    text: 'File',
    items: [
      await MenuItem.new({
        id: 'newProject',
        text: 'New Project',
        action: () => {
          // console.log('newProject')
          newProject()
        },
      }),
      await MenuItem.new({
        id: 'openProject',
        text: 'Open Project',
        action: () => {
          // console.log('openProject')
          openProject()
        },
      }),
      await MenuItem.new({
        id: 'saveProject',
        text: 'Save Project',
        action: () => {
          // console.log('saveProject')
          saveProject()
        },
      }),
    ],
  })
  const editMenu = await Submenu.new({
    text: 'Edit',
    items: [
      await PredefinedMenuItem.new({
        item: 'Undo',
      }),
      await PredefinedMenuItem.new({
        item: 'Redo',
      }),
      await PredefinedMenuItem.new({
        item: 'Separator',
      }),
      await PredefinedMenuItem.new({
        item: 'Cut',
      }),
      await PredefinedMenuItem.new({
        item: 'Copy',
      }),
      await PredefinedMenuItem.new({
        item: 'Paste',
      }),
      await PredefinedMenuItem.new({
        item: 'SelectAll',
      }),
    ],
  })
  const viewMenu = await Submenu.new({
    text: 'View',
    items: [
      await PredefinedMenuItem.new({
        item: 'Fullscreen',
      }),
    ],
  })
  const windowMenu = await Submenu.new({
    text: 'Window',
    items: [
      await PredefinedMenuItem.new({
        item: 'Minimize',
      }),
      await PredefinedMenuItem.new({
        item: 'Maximize',
      }),
      await PredefinedMenuItem.new({
        item: 'Separator',
      }),
      await PredefinedMenuItem.new({
        item: 'CloseWindow',
      }),
    ],
  })

  const menu = await Menu.new({
    items: [dumyMenu, fileMenu, editMenu, viewMenu, windowMenu],
  })

  const res = macOS ? await menu.setAsAppMenu() : await menu.setAsWindowMenu()
  return res
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions