well its tuesday, but I was with family yesterday...
Late last week @cibernox reported that emberjs/ember.js#11748 was still leaking for him.
As it turns out, the main leak was forgetting to null
out top levels vars in afterEach. But that kinda sucks, as it is tedious and error prone.
So instead I wanted a better solution, one where the purden was not on the test writers.
So, as it turns out we can also just release the ES2015 module after requiring it, allowing the JS GC to do the work for us.
The follow commits add the ability to unsee a module in the loader, and configure the test-loader to unsee after requiring.
- https://github.com/ember-cli/ember-cli-test-loader/commit/2fca180d7f585a6863fb03e2b13db5adc8af55c5
- https://github.com/ember-cli/loader.js/commit/13137fc165507d57a78ce3faff7e647de91e379c
With this in-place, we still saw some leaks, after some voodoo, we realized it was a bug in QUnit itself.
A quick PR later: qunitjs/qunit#842 and we have demonstrated no more app leaks.
Up-next we noticed pretender was leaking, after a quick scan the fix was apparent.
With these in-place, we still leaked some mirgate/pretender servers, a short term fix was the following:
afterEach(function() {
Ember.run(app, 'destroy'):
server.shutdown(); // be sure to shut down the server
window.server = undefined; // mirage leaks a global server, which must eventually be released.
});
Future work, should:
- shutdown the server automatically miragejs/ember-cli-mirage#226
- either not rely on a global, or ensure the global
server
is purged after a test run. miragejs/ember-cli-mirage#225