machty / ember-concurrency

ember-concurrency is an Ember Addon that enables you to write concise, worry-free, cancelable, restartable, asynchronous tasks.
http://ember-concurrency.com
MIT License
691 stars 157 forks source link

Issues using async/await with stubbed promises #408

Closed BarryThePenguin closed 6 months ago

BarryThePenguin commented 3 years ago

👋🏻

This is my first expedition into the ember-concurrency source 👀 ember-concurrency is a joy to use, especially with the new TypeScript additions

I've put together a reproduction of an issue I ran into while upgrading to ember 3.24

There's two tests..

  1. "sinon stub promise that fails"
  2. "sinon stub promise that passes"

In both an async method is stubbed with sinon.stub(obj, 'sinonPromise').rejects('An error').

Then the test calls await obj.tryDoStuff() which performs a task that yields the stubbed method.

In the first test I can see asyncErrorsHandled is not set on the task.

That's about as much information as I can provide 😅

BarryThePenguin commented 3 years ago

I think this might be closely related to #409 too..

maxfierke commented 3 years ago

@BarryThePenguin is there a way you can reduce this down to a case without sinon? If there's a generalizable reproduction, it might make it easier to determine what's going on without having to disentangle what sinon might be doing (as much as I like sinon, there's fair amount of indirection, typically)

I agree, it does sound like it might be similar to #409 but a generalizable test case can help us confirm

BarryThePenguin commented 3 years ago

I don't know if the latest changes provide much more info.. it's essentially doing the same as sinon.stub(), but we're replacing functions on the instance manually instead..

maxfierke commented 3 years ago

There seems to be a variance based on version, indicating perhaps there's some dependency difference at play. I ran the tests against master:

AFAICT, there haven't been any updates to RSVP or Backburner that I would typically expect would impact this, but I'll keep digging