Require await on all Promises #1993
Labels
priority: P3
Useful but not urgent
status: archived
Archived and locked; will not be updated
type: code health
A code health issue
Have you read the FAQ and checked for duplicate open issues?
Yes
Is your feature request related to a problem? Please describe.
With the transition to async/await, there are a lot of cases where we just ignore the Promise that is returned. This is fine for async work, but means that errors can be easily ignored. We still did this before with ignored Promise chains, but is probably more prevalent now with async/await.
Describe the solution you'd like
We should have something that checks that we "use" the returned Promise. We might be able to write a compiler plugin to do this. Since the compiler knows the types of fields and return values, we might be able to track the Promise variables and verify they are either in an "await" or returned.
There are many cases where we want to "start" a job but not wait for it to be completed. For example, in StreamingEngine we have several cases where we don't want to block the caller but the operation is asynchronous. We could create some wrapper that can be used to monitor these async events and call an onError handler if something goes wrong. This will also make the code clearer when we want to start async work vs just forgetting to use await.
There is also the case where we use event listeners that are async. Event listeners are synchronous and even ignore thrown exceptions. Since we use our
EventManager
, we can use that to wrap any event callbacks to handle this. We can catch any thrown exceptions and also monitor any Promises that are returned.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: