question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

backburner >=2.2.0 (ember >=3.2.0) breaks tests which are using fake timers of sinon/lolex

See original GitHub issue

This bug was introduced by the following commit and is included in all backburner releases since 2.2.0: backburnerjs/backburner.js@27690deba7a9122e036088a603f4f0374c3ba2af

I wasn’t sure whether this issue should have been opened on the ember issue tracker or here, but since the bug is included in this repo, I thought this was the right place.

I’ve created a simple Ember app repo to demonstrate this issue. This demonstration-app is basically just a simple component with a debounce call and Sinon’s useFakeTimers method for testing the debounce behavior on a simple class name binding. bastimeyer/backburner-settimeout-bug@3739940aeb7768aa47e66a18ab4359c12275a8fb bastimeyer/backburner-settimeout-bug@08cb10e02d3c391b83dc3c3ee1e7d10760f7bb73

Upgrading ember-source to >=3.2.0 which includes backburner >=2.2.0 breaks this test by throwing a TypeError: Uncaught TypeError: Cannot read property 'apply' of undefined


The issue is caused by a static reference of setTimeout in some backburner methods which can’t be replaced on the global/window context by sinon or lolex after the useFakeTimers method has been called: https://github.com/BackburnerJS/backburner.js/blob/v2.3.0/lib/backburner/platform.ts#L9 https://github.com/BackburnerJS/backburner.js/blob/v2.3.0/lib/backburner/platform.ts#L33 https://github.com/BackburnerJS/backburner.js/blob/v2.3.0/lib/backburner/platform.ts#L38

If you replace the SET_TIMEOUT reference with simple setTimeout calls in the built ember-source/dist/... file and re-run the test, everything is working just fine.

I’m not sure why this SET_TIMEOUT constant was added, but since I don’t know anything about the internals of this project either, I didn’t want to submit a PR. This looks like a simple mistake, though, because there’s an unused SET_TIMEOUT constant in the main backburner module here which lead to this bug: https://github.com/BackburnerJS/backburner.js/blob/v2.3.0/lib/index.ts#L26 https://github.com/BackburnerJS/backburner.js/commit/27690deba7a9122e036088a603f4f0374c3ba2af#diff-13b5b151431c7e7a17f273559ed212d5L212


Backburner >=2.2.0 is now being used in all Ember releases since 3.2.0, which makes me unable to upgrade my applications from ember 3.1.4 to a newer release. I’d appreciate if older versions could get a patch release, too, after this gets fixed.

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Sep 27, 2018

#352 should address

0reactions
rwjbluecommented, Nov 21, 2018

@BillyRayPreachersSon you shouldn’t need an ember-cli version bump to be able to get ember-source@3.4.x, you can bump your apps own dependency on ember-source as needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[3.2.0-beta.2] Operand over 16-bits. Got 65536 #16532 - GitHub
After the fix for #16503 I updated from 3.0.0 and I am seeing this after a couple route transitions instead of the previous....
Read more >
Upgrading Ember - Issues with Tests - Questions
So I took on the task of upgrading our Ember app from 2.16 to 3.26. ... baseURL and rootURL settings should not be...
Read more >
How to use sinon.useFakeTimers with ember-testing ...
I think in all cases sinon.useFakeTimers() is breaking the async and sync helpers (in this case the andThen() ). I've tested with something...
Read more >
Ember Timer Leaks: The Bad Apples in Your Test Infrastructure
Is using the wait helper causing test timeouts? You may have a leak. This section makes references to “leaking timers,” a timer that's...
Read more >
Writing Unit tests in Ember 3.0 - YouTube
In this video, I cover some of the basics of unit testing with in an ember project using the latest version of ember.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found