ember-concurrency icon indicating copy to clipboard operation
ember-concurrency copied to clipboard

Using yield* in finally blocks fails

Open msz opened this issue 7 years ago • 2 comments

Since it's possible to yield in finally blocks, I would expect to also be able to hand off the yielding to another generator using yield*, but this seems to fail. yield*ing in try blocks works without an issue.

Reproducing

I have created a test based on the promise yield test which uses generators instead. https://github.com/msz/ember-concurrency/tree/failing-test-finally-generator-yield

Expected

The test should pass and handing off to another generator should not affect the result.

Actual

When the first *yielded generator is reached, the generator function is not executed, and the task abruptly ends.

msz avatar Nov 09 '17 19:11 msz

In general, e-c doesn't really have a fleshed out story for async teardown; it kind of expects that when a task is canceled, it expects the task to return and finish up in a synchronous step. It's not so much an implementation difficulty than it is conceptual, e.g. if you have a restartable() task that takes 3 seconds to clean up when it's canceled, should the newly performed task wait until the prior task completed teardown? or should it start running right away? I think we'd need to figure out these things before I'd know how to address this issue.

machty avatar Nov 09 '17 21:11 machty

I see. So this means async teardown, including yielding Promises, is not fully supported right now, correct?

msz avatar Nov 10 '17 13:11 msz