Comments (7)
I think there are only a couple areas (at the edge of the world, basically) where we forcibly print the stack trace. In most cases, we rely on ExecutionContext#reportFailure
, which defaults to delegating to IOApp#reportFailure
, which can be overridden to whatever you want. I think it would be totally reasonable to swap these last printStackTrace()
s for reportFailure
on the IORuntime#compute
executor, which would link all of the machinery back together again.
from cats-effect.
Usual failure reporter (i.e., ExecutionContext#reportFailure
) have the following signature: Throwable => Unit
, whereas for IOApp#reportFailure
it is Throwable => IO[Unit]
. Did you have that in mind in your comment above?
I also wouldn't rely on (or require) an IOApp instance to be available and in scope.
Wouldn't it be better to do it the other way round? i.e., rely on an UncaughtExceptionHandler
, and call it from everywhere (via ExecutionContext#reportFailure
) and from IOApp#reportFailure
's default implementation?
from cats-effect.
Usual failure reporter (i.e., ExecutionContext#reportFailure) have the following signature: Throwable => Unit, whereas for IOApp#reportFailure it is Throwable => IO[Unit]. Did you have that in mind in your comment above?
I was thinking of runtime.compute.reportFailure
, which has signature Throwable => Unit
. That should work for both of the IO
call sites which print stack traces. Dispatcher
might be another interesting question, but in that case we do actually have a running IOApp
somewhere, so we can probably work around it by just submitting things back to the worker via Dispatcher#unsafeRunAndForget
.
Wouldn't it be better to do it the other way round? i.e., rely on an UncaughtExceptionHandler, and call it from everywhere (via ExecutionContext#reportFailure) and from IOApp#reportFailure's default implementation?
What thread though? One of the problems here is the fact that this callback will be invoked on a different thread than you might be expecting, and likely one which is under the control of the IORuntime
not under user control. In that kind of scenario it simply isn't worth delegating through the Thread
machinery when the ExecutionContext
machinery is already in hand and more efficient.
from cats-effect.
I've seen quite a few cases where an IORuntime
, and Dispatcher
s are used but there's no IOApp
anywhere. With that in mind, would it make sense to assume we'll rely on failure reporters of IORuntime
(i.e., runtime.compute.reportFailure
), and make sure those are configurable somehow (when an IOApp is used, IOApp#reportFailure
is used to configure the failure reporter of the IORuntime somehow)?
from cats-effect.
The reportFailure
parameter of the IORuntime
constructor takes a function Throwable => Unit
. This is what IOApp
is wiring up to the IOApp#reportFailure
method.
I think that all that really needs to be changed here is the hard-coded printStackTrace
should be replaced with a runtime.compute.reportFailure
. We should probably also check that Dispatcher
has the equivalent change.
from cats-effect.
Please have a look at this proposal, it is minimal in that:
- it assumes usage of an
IOApp
(i.e., didn't check yet if the same could be achieved for those creating anIORuntime
oustside of anIOApp
) - doesn't work for anything outside of the
IOApp.run
(especially error handling related to what's pulled fromcats.effect.IOApp.queue
There are also a few usages of System.err
for error reporting, I'd be tempted to find a similar way to allow redirecting them to another facility, thoughts on that?
from cats-effect.
Also, the proposed fix would need to be slightly adapted if #4010 is accepted
from cats-effect.
Related Issues (20)
- better handling of callbacks that might throw in `CallbackStack` HOT 1
- Improve `MonadCancel` scaladoc HOT 4
- Cancelling `Async` queue `take` makes other `take` hang HOT 5
- `IO#asyncCheckAttempt` is inconsistent with `Async#asyncCheckAttempt`
- Improve contributor documentation HOT 3
- Add (best-effort) stealing API to polling system
- Add API to polling system to attempt to get current poller without shifting HOT 6
- More efficient monitoring of fibers on virtual threads HOT 1
- Published tutorial older than tutorial.md HOT 1
- OutOfMemoryError when IO.uncancelable is used in recursive function HOT 3
- unsafeToFutureCancelable's cancel future completes before setting the result future's cancellation status HOT 7
- unsafeToFuture fails to raise a second InterruptedException if the exception is handled and retried HOT 6
- Support for V8 JavaScript Engine? HOT 2
- IO.onError is inconsistent with ApplicativeError HOT 3
- `AsyncSpec` failure (ciJS)
- When `IORuntime.global` shuts down, it doesn't shut down the WSTP HOT 1
- Queued but unstarted work on `Dispatcher.sequential` should be cancelable HOT 6
- Release for Scala Native 0.5.x HOT 1
- Consolidate duplicate "currently executing fiber" pointers
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cats-effect.