-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: cache local environment values (#120)
Yes this is a bit dirty because the report is now generated once at the beginning of a command which could be considered a side effect (but normally treeshaking will only include it only if needed), but the whole process.report is a weirdly built API meant for debugging and not really meant to be used in a normal program But somehow when the call is done in the beginning of the process, this call is very fast, but when it's called after having run a http request (as is currently the case, a single call takes a lot more time to complete, it takes 40s or more on my system when called at the end of npm upgrade) but only a few milliseconds when called at the beginning (this is why it's best to run it outside the function at the beginning of the process as a side effect instead of calling getReport on demand and cache the result) Here is a log of console.time('report') and console.timeEnd('report') before and after the getReport call when run in the end of the upgrade command: ⠼report: 3:10.573 (m:ss.mmm) when run in the beginning of the process at the top level report: 1.943ms This fixes npm hanging npm/cli#4028, npm/cli#7814, npm/cli#7868
- Loading branch information
Showing
2 changed files
with
114 additions
and
33 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