-
-
Notifications
You must be signed in to change notification settings - Fork 89
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
Error reporting difference between Sync{} and Async{}.wait #299
Comments
Looking a bit deeper, this is because This seems like an unfortunate difference to me between |
I'm familiarizing myself with the implementation of async a bit more, and realizing that my earlier analysis is a little off. In top-level calls to both I don't know the intent here in setting an explicit Anyway, I'm glad I understand it more fully now. But I'm not sure that helped steer me closer to what should change here -- assuming the maintainers agree something should change. I do think it'd be beneficial to not have this logging gotcha, though. |
I'm also encountering this issue but the other way around: top-level I could be missing something but it feels to me that the exception should only be logged when nothing is awaiting on it. Wouldn't the code be able to detect that? |
Sorry, I never followed up this discussion/issue. I have experimented, mostly unsuccessfully, to try and improve this code/behaviour. In the past, I experimented with removing it entirely. It was such a bad developer experience - stuff would fail and you'd have no idea. When I first created this, I was strongly in favour of logging all failures - i.e. silent failures should never happen. But you are absolutely right: When I thought about introducing With that in mind: require 'async'
Sync {
Async { loop { sleep 1 } }
raise "whoops"
} I wonder if we could make this code immediately exit the event loop. In other words, a top level |
That sounds like a great solution. Preferably, the top level |
I also like that idea. What do you think about top-level Async (not wrapped in Sync) to re-raise as well, even if not being awaited on? In other words, never log and always re-throw at the (blocking) top level. |
Hi, I recently tracked down a tricky silent failure related to switching from
Async
toSync
at the top level, as the best practices doc suggests. An exception in the top-level task was being silently swallowed and not reported, so it took a long time to track down why the service was sometimes not behaving. Here is a minimal reproduction:This code just hangs indefinitely without logging the unhandled exception. This code is silly of course, but hopefully you can see how this could arise in practice -- in the actual application, the root task reads input and passes a queue to each long-lived async sub-task to communicate back to the root task. If the root task raises a StandardError due to a bug, it's dead, but the reactor is still waiting on its sub-tasks which are running in a loop so nothing is ever logged or otherwise reported.
But what's interesting is that if you change the top-level
Sync{}
toAsync{}.wait
, then the exception is logged in the normalTask may have ended with unhandled exception.
way, though it still hangs indefinitely afterwards. But that logging would've been key here. It's not clear to me just looking at the code for the Async and Sync methods why this behavior might be different, I'd need to look at the Reactor impl more closely.In hindsight, I likely should refactor to have a top-level supervisor task which is the parent of the current root task, since that one is doing a lot of actual I/O work, but this still seems worth probably addressing.
Marginally related, I really wish async didn't just log StandardError failures and continue on, I prefer hard failures on all unhandled exceptions. It'd be nice if the async library had a way to bubble up all unhandled exceptions or register a callback for unhandled errors or something. But that seems like a separate discussion that I should open at some point once I've thought it through further.
The text was updated successfully, but these errors were encountered: