Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skipped child module hooks are leaked #1649

Closed
bendemboski opened this issue Sep 2, 2021 · 0 comments · Fixed by #1650
Closed

Skipped child module hooks are leaked #1649

bendemboski opened this issue Sep 2, 2021 · 0 comments · Fixed by #1650
Labels
Component: Core For module, test, hooks, and reporters. Type: Bug Something isn't working right.

Comments

@bendemboski
Copy link
Contributor

Tell us about your runtime:

  • QUnit version: 2.14, 2.16
  • Which environment are you using? (e.g., browser, Node): both browser & Node
  • How are you running QUnit? (e.g., QUnit CLI, Grunt, Karma, manually in browser): Ember tests & CLI

What are you trying to do?

Execute a test run that filters out some child modules that have hooks.

Code that reproduces the problem:

import { module, test } from 'qunit';

class Foo {}

module('parent', function(hooks) {
  let foo1;

  hooks.beforeEach(function() {
    foo1 = new Foo();
  });

  test('foo1 is ok', function(assert) {
    assert.ok(foo1);
  });

  module('child', function(hooks) {
    let foo2;

    hooks.beforeEach(function() {
      foo2 = new Foo();
    });

    test('foo2 is ok', function(assert) {
      assert.ok(foo2);
    });
  });
});

Run with filter=!child so the child module is not executed.

What did you expect to happen?

foo1 and foo2 are garbage collected after the test run because of the code that deletes module hooks out of the global config.

What actually happened?

They are not because the child module's tests never execute, so the child module never "completes" and its hooks are never deleted out of the global config.

bendemboski added a commit to bendemboski/qunit that referenced this issue Sep 2, 2021
Make sure that even if a module is entirely skipped, its hooks are deleted out of the global config so that they don't cause data they reference to leak.

Fixes qunitjs#1649
@Krinkle Krinkle added Component: Core For module, test, hooks, and reporters. Type: Bug Something isn't working right. labels Sep 5, 2021
Krinkle pushed a commit that referenced this issue Sep 5, 2021
If a module is skipped, the hooks of chid modules should be deleted
as well from our global config so that references to memory held
by these closures may be released.

Fixes #1649.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core For module, test, hooks, and reporters. Type: Bug Something isn't working right.
Development

Successfully merging a pull request may close this issue.

2 participants