Skip to content

Instantly share code, notes, and snippets.

@stefanpenner
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanpenner/ca157da6d74ea624ed36 to your computer and use it in GitHub Desktop.
Save stefanpenner/ca157da6d74ea624ed36 to your computer and use it in GitHub Desktop.

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.

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment