-
-
Notifications
You must be signed in to change notification settings - Fork 157
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
Async Error Handler Running Synchronously #409
Async Error Handler Running Synchronously #409
Comments
Comparing stack traces between my app (with the problem) and the In terms of the actual methods being queued, in this code: The Ember Concurrency async error-handler is run synchronously if |
Mind sharing some code from the task too? Mostly curious about whether the error is happening before or after the first |
Before -- this is the task definition @task
*requestCertificate() {
if (!this.customDomainCertificate.domain) {
const error = new Error();
error.type = 'domain';
throw error;
}
yield this.customDomainCertificate.save();
yield this.customDomainCertificate.request();
yield this.customDomainCertificate.fetchValidationRecords();
} |
Interestingly, I updated |
Maybe, to ensure that the async error handler is actually called asynchronously, we could use |
@alexlafroscia can you share the test case here or in a PR? Using I think we roughly used |
@maxfierke very-much-messy PR opened with the test I wrote into the test suite that fails |
having a bit of difficulty reducing this, but curious what happens if you do Tried reproducing it outside of a helper, and I can't :/ |
Alrighty, I think I'm starting to get a handle on this. To be clear: the error reporting is happening asynchronously, but there's an ordering issue in which the uncaught error reporting is running before the Seemed to be able to fix the failing tests by wrapping the call in |
Alright, root cause here seems to be due to the |
Sounds good! Thanks for getting to the bottom of this!! |
Thanks again @maxfierke for putting so much effort into this admittedly-obscure bug! |
I'm running into a pretty bizarre error while trying to upgrade our app to
ember-concurrency@2.0.2
(from the latest pre-2.0.0
release).It seems that the async error handler defined here is in fact running synchronously, and prempting our own error handling.
We have a
swallow-error
helper that we sometimes use for cases where an Ember Concurrency task would expect an error to be thrown and we use the derived error state on the task instance to show it to the user. Because we error will be "handled" in the UI itself, we want to swallow the error entirely.swallow-error
helper sourceIn the current version of
ember-concurrency
that we're using, this works just fine.In
ember-concurrency@2.0.2
, it seems like the code here that should report the error if it was not already caught is being executed synchronously when it should be executed asynchronouslyember-concurrency/addon/-private/external/task-instance/executor.js
Lines 344 to 348 in 35a188c
I know it's a challenge to grok a stack trace without much context, but this is what I'm seeing; a single synchronous trace from my
debugger
point inside the error-reporting callback that should be run asynchronously straight down to the function invocation insidecallAndSwallowError
.I know that
env.async
is usingjoin
from the@ember/runloop
package, which will insert the callback into the current queue. My guess is that Backburner is calling things in the current queue before proceeding with execution of the code in my helper... for some reason. My code isn't doing anything directly with the runloop; there's just the normal amount of wrapping that helper invocations have by default at play.I tried to create a failing test case in the
ember-concurrency
repository but have been unable to get the same error to occur there just yet. I will post a PR with that once I have it.I'm wondering whether a potential fix could be specifically scheduling the
async
callback into the next run loop, rather than usingjoin
which can insert it into the current "tick".The text was updated successfully, but these errors were encountered: