max-mapper / max-mapper/menubar
Error: Object has been destroyed when sending message from Main to Renderer
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.8k
- Forks
- 363
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am trying to send a message from Main to the Renderer and whenever I do, I get "Error: Object has been destroyed"
I can't figure out if I'm doing something incorrectly or if this is not possible with menubar.
I have successfully gotten messages to send to the menubar renderer when it is already open using the event reply method:
ipcMain.on('testFromRenderer', (event) => {
event.reply('responseFromMain', 'responseContent')
})
However, I get an error when I try to trigger an event that isn't a direct response to an event from the Renderer
mb.window.send('triggerFromMain')
mb.window.webContents.send('triggerFromMain')
const mb = menubar({
browserWindow: { webPreferences: { nodeIntegration: true } },
dir: APP_PATH,
icon: path.resolve(APP_PATH, './icon.png'),
preloadWindow: true,
showDockIcon: false,
showOnAllWorkspaces: true,
tooltip: 'Runner',
})
I create the menubar in one file and am trying to send this message from a very different part of the codebase. I have tried importing it, and also tried attaching mb to global. Not sure how to best approach this.
Steps to Reproduce the Problem
- Create a new menubar
- Attempt to send a message from Main
Expected Behaviour
Should be able to send a message
Actual Behaviour
Error: Object has been destroyed
Specifications
- Menubar version: 7.2.0
- Platform: OSX Catalina 10.15.1
- Electron version: 7.1.10 (Run
electron -vornode_modules/.bin/electron -vto get it)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the menubar creation shown in the issue and trace the ipcMain, mb.window.send, and mb.window.webContents.send calls. Reproduce the error using the stated menubar 7.2.0 and Electron 7.1.10 versions, then verify that a main-process message can be sent when the renderer is open without producing "Object has been destroyed".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- desktop-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100