Skip to content

HOW TO: Find a specific global leak

Christopher Hiller edited this page Oct 10, 2017 · 1 revision

Detecting which module is causing a global leak can be tedious. Add these lines at the very beginning of your tests, or in a file which is included via --require:

Object.defineProperty(global, "name_of_leaking_property", {
  set: function(value) {
    throw new Error("Found the leak!");
  }
});

This will print a stacktrace that shows which module caused the leak. And if it's not yours - go open a pull request! :)