-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signals: re-throw exceptions in handlers #45
Comments
Problem: for synchronous events (triggered by a js function), errors are thrown correctly, but for asynchronous events (eg callback when a user presses a key) the errors are not thrown the same way. The error is then noticed in some other part of the code, when we try to unwrap a Synchronous: const entry = new Gtk.Entry()
entry.on('editing-done', () => { throw new Error('test') })
entry.editingDone() Asynchronous: const entry = new Gtk.Entry()
entry.on('key-press-event', () => { throw new Error('test') })
// user presses a key |
|
Ok, got more infos: the problem is that when an error happens inside a signal handler callback and PyGObject seems to wrap @override(Gtk.main)
def main(*args, **kwargs):
with register_sigint_fallback(Gtk.main_quit):
with wakeup_on_signal():
return _Gtk_main(*args, **kwargs) PyGObject doesn't have a dependency on So I'm not sure if that's what they're doing, but we could try to achieve something similar, and emit a SIGINT in |
isn't the libuv event loop nested inside the GTK event loop? This should allow 'uncaughtException' to be thrown. |
Yes, it is nested inside the Gtk event loop. I don't know if it should allow it, but it's not the current behavior. The I'll maybe check a few more bindings implementations, and I'll implement it as PyGObject above if I don't find any other magical trick. (Ping @magcius, following your comment, if you have any hints that could help here it would be awesome!) |
What in V8 emits the uncaughtException handler? Did you guys integrate the more robust threading solution made for eos-knowledge-node-content for mainloop nesting? |
No, it's not integrated and I don't know what it is. Do you have any links to eos-knowledge-node-content? Meanwhile, it seems that /*
* Gtk-3.0.js
*/
exports.apply = (Gtk) => {
const originalMain = Gtk.main
Gtk.main = function() {
process.on('SIGINT', () => {
console.log('SIGINT raised') // Never called
Gtk.mainQuit()
})
originalMain()
}
} |
Yes, that's it. See this comment in node-gir: Place1/node-gir#24 (comment) Otherwise, I do pump the libuv event loop, so if uncaughtException happens because of that, it should be fine. Looking at what happened, it seems that someone ported the closure.cc code to NaN (as I pleaded when people started developing this, please don't use NaN, it doesn't work), and NaN automatically captures exceptions and automatically ticks the mainloop, according to this comment: nodejs/nan#284 (comment) |
There's apparently some replacement for NaN called N-API now, but I've never used it. |
I've tried removing all NaN stuff from I've read a bit about N-API and it seemed interesting, but not enough to warrant a re-write. I've started the integration of mainloop nesting of eos-knowledge-node-content loop solution in #52, but after some testing, it doesn't seem to fix the issue here (though it might fix other issues). I'll keep investigating what's going on. |
I still assume something is just capturing the exception somewhere. |
Got it, will investigate further.
Essentially, we'd just need to call |
So I went a different direction to solve this, I created a @magcius, how did the solution for endless work for you? What problems did it solve, or on what aspects is it better than the previous loop.cc you wrote? |
The goal of the Endless solution was to let both the Electron/Chromium and glib event loops run in parallel. If we think this is an issue where gtk_main() pauses the libuv loop and my hack to pump it isn't working, the thread solution could be something to try. |
Pass
tests/object__signal__throws.js
The text was updated successfully, but these errors were encountered: