Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only activate once, when on (#1824)
While debugging the Jest memory leak, I was surprised to find the Nock was "activating" twice when imported. This is because intercept.js was calling `activate()` directly _AND_ back was setting the mode, which calls `restore()` and `activate()`. There is no need for this double initialization. Think of the CPUs we could be saving. I also discovered that Nock "activates" even if the proc is started with the `NOCK_OFF` env var set, which means Nock is polluting the global scope even when callers have asked it not to. Since it felt like the `back.setMode()` call was hiding in its module, I've moved it to the entry index file and wrapped it in a `isOn` check.
- Loading branch information
1 parent
8b8a10d
commit a56a209
Showing
5 changed files
with
23 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters