The electron program always prompts you to exit unexpectedly after macOS is closed

< H2 > question < / H2 > The

program runs normally. After executing app.quit () or pressing < kbd > quit < / kbd > + < kbd > Q < / kbd >, the program is always prompted to exit unexpectedly, with a probability of 101% (whether it"s dev or packaged macos applications)

. < H2 > error screenshot: < / H2 >

clipboard.png

< H2 > main.js Code: < / H2 >
const path = require("path")
const { app, BrowserWindow } = require("electron")
const { creatTray } = require("./tray")
const { createWindow } = require("./window")

const { NODE_ENV } = process.env

let tray

if (NODE_ENV === "development") {

  // react-developer-tools
  require("electron-debug")({ showDevTools: false })
  app.on("ready", () => {
    let installExtension = require("electron-devtools-installer")
    installExtension.default(installExtension.REACT_DEVELOPER_TOOLS).then(() => {

    }).catch(err => {
      console.log("Unable to install `react-developer-tools`: \n", err)
    })
  })
}


app.on("ready", () => {
  tray = creatTray()
  createWindow("home")
})

app.on("window-all-closed", e => {
})

app.on("quit", e => {
  tray.destroy()
})
Oct.27,2021

excuse me, has this problem been solved?


the reason has been found. There will be a problem with destroying the tray icon when the program exits in macos.
in fact, the macos program automatically destroys the tray icon when it exits.

"electron": "2.0.7",

solution:

destroy pallet icons manually only under win system (or not manually only under macos)

error code:

app.on('quit', e => {
  tray.destroy()
})

Correction:

app.on('before-quit', e => {
  //  win 
  if (process.platform === 'win32') {
    tray.destroy()
  }
})
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e46225-44ba2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e46225-44ba2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?