You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Application closes when destroying tray object #6956
I am trying to randomize the "content" of the display bubble. I have re-written the code to make this work, but when the setTimeout is called to kill the tray the application closes completely with no errors in the console. This seems to be a bug. Since it should just delay the destruction of the tray, not kill the application.
Whatever else is going, this won't delay anything:
setTimeout(tray.destroy(), 2000)
You're just passing the return of value of tray.destroy() to setTimeout(). that value is probably undefined, though I think setTimeout() will just ignore that.
Can you provide an minimum sample application that reproduces this issue. It's hard to even guess at what is going on when we don't know what fires 'timer-done' or what createTray does.
Worth noting as @enlight said that your timeouts probably want to be
let tray = null
var createTray = function() {
tray = new Tray(`${__dirname}/img/app.png`)
const contextMenu = Menu.buildFromTemplate([
{label: 'Start Timer',
click(item) {
mainWindow.webContents.send("start");
}
}
])
tray.setToolTip('Timer Settings for SitTimer.')
tray.setContextMenu(contextMenu)
}
A renderer process is running a timer and after a set amount of time ipcRenderer.sendSync is triggering on "timer-done" event.
I have since taken the setTimeout function out, because I realized I didn't have to regenerate the tray every time to change the "content" of the bubble, but since it the application quit on me when I had the code this way, I figured this might be related to a bug, which should be reported.
Removing the setTimeout Functions fixed it for me.
I am working on getting a recreatable barebones and a stack dump. Although I can do what I want, should we not try to trace why this is happening? If not, we can close the issue and I will move on.
I think that i've got it, just wrap the .destroy() in a setTimeout() like this:
setTimeout(()=>{myTray.destroy()},0)
I don't understand why this issue was closed and even was not created on Node or V8 (if is their issue), furthermore, if we wrap the call on electron with the setTimeout should solve this right?
@Negan1911 I closed it, since I changed my code away from the use of setTimeout. This is 2 years ago and I can't remember why I did not create a new issue with Node or V8, but honestly I probably dug just deep enough to come to the conclusion that it wasn't electron that was causing the issue. (I'm not a professional coder)
Activity
enlight commentedon Aug 24, 2016
Whatever else is going, this won't delay anything:
You're just passing the return of value of
tray.destroy()to setTimeout(). that value is probablyundefined, though I think setTimeout() will just ignore that.MarshallOfSound commentedon Aug 24, 2016
Can you provide an minimum sample application that reproduces this issue. It's hard to even guess at what is going on when we don't know what fires
'timer-done'or whatcreateTraydoes.Worth noting as @enlight said that your timeouts probably want to be
Dletta commentedon Aug 24, 2016
Thanks @enlight and @MarshallOfSound, I slapped my forehead after reading your comments.
The create Tray function is as follows
A renderer process is running a timer and after a set amount of time ipcRenderer.sendSync is triggering on "timer-done" event.
I have since taken the setTimeout function out, because I realized I didn't have to regenerate the tray every time to change the "content" of the bubble, but since it the application quit on me when I had the code this way, I figured this might be related to a bug, which should be reported.
Removing the setTimeout Functions fixed it for me.
MarshallOfSound commentedon Aug 24, 2016
Without a crash dump, error log or minimum code that reproduces the issue there isn't much anyone can do.
You can see crash dumps (if there is one) by setting the environment variable.
zeke commentedon Aug 24, 2016
Looks like this issue is resolved, yeah?
Dletta commentedon Aug 24, 2016
I am working on getting a recreatable barebones and a stack dump. Although I can do what I want, should we not try to trace why this is happening? If not, we can close the issue and I will move on.
Dletta commentedon Aug 24, 2016
The stack dump says this:
When I use the setTimeout correctly with the functions executing the function, such as I should have been using them, the application does not exit.
Dletta commentedon Aug 31, 2016
It seems it is caused by the way Node and V8 implement their timers. Close for Electron, thank you
nalejandroveron commentedon Apr 25, 2018
I think that i've got it, just wrap the
.destroy()in asetTimeout()like this:I don't understand why this issue was closed and even was not created on Node or V8 (if is their issue), furthermore, if we wrap the call on electron with the setTimeout should solve this right?
Dletta commentedon Apr 25, 2018
@Negan1911 I closed it, since I changed my code away from the use of setTimeout. This is 2 years ago and I can't remember why I did not create a new issue with Node or V8, but honestly I probably dug just deep enough to come to the conclusion that it wasn't electron that was causing the issue. (I'm not a professional coder)
nalejandroveron commentedon Apr 25, 2018
@fuchidahiro oh sorry mate, i tought that was closed by a mantainer, my bad!
This continues on #9982