-
Notifications
You must be signed in to change notification settings - Fork 70
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
Errors in callbacks don't terminate the loop #284
Comments
Well, I set a breakpoint on Before the
After the jump:
So, apparently LGI uses For your test case, the warning comes from here: Lines 1346 to 1354 in 4071f90
This is the code for calling a function and this seems to turn a Lua error into a The Lines 1373 to 1377 in 4071f90
So, yeah, dunno what to do here and I doubt what LGI is currently doing is legal / allowed / a good idea... |
Oh and for what the guide says: I guess that he guide is outdated for almost eight years now. A little git-digging suggests that #86 changed things so that "call errors" are not simply propagated out. Back then, the coroutine case already existed, but apparently no one though of fixing that so that it also doesn't let the error propagate. And of course no one updated the docs. |
#86 looks to me like it only added the warning message and that the behaviour didn't change. That |
The change is subtle: Previously, there was a
I guess you already know that, but just to be sure: To hit that case, you need to provide a coroutine instead of a function as the callback. (And: I consider this a bug and would want to make the behaviour between both cases the same, but am currently to lazy to do this. Thus, if I ever become non-lazy (I doubt it), your code will break.) |
As the
corocbk.rethrow
test shows, errors that happen directly inside an idle source stop the current loop and are returned byloop:run()
.However, when the error occurs somewhere nested inside callbacks, the callback chain is aborted, but the error is swallowed.
In the following minimal example, if the
query_info
operation fails, the error will be printed as GLib warning, but the loop will not quit immediately.Only once the timeout hits will the loop stop, but report a "successful"
true, nil
.The Guide suggests that these errors should either terminate execution or trigger a
pcall
, neither of which happens here.Result:
Related: #124.
The text was updated successfully, but these errors were encountered: