Closed SuhairZain closed 6 years ago
Hi @SuhairZain since this is a closed-source project and you can't share a full repro, I'll need your help tracking down the bug on your end.
I suspect problem might come from a dependency loop that ts-unused-exports
does not detect, and thus gets stuck fetching and loading the same files over and over until it runs out of memory.
Could you console.log({ path, otherFiles: otherFiles.map(f => f.path) })
before this line ./node_modules/ts-unused-exports/lib/parser.js:182 and check the output to see if you find some strange pattern (i.e. a path that appears in both arrays, repeating calls with the exact same values for both arrays, etc.)
Maybe you could share just that output. Note that that will disclose filenames but not file content (do check with your team if that is OK for your project).
Just out of curiosity, could you share some stats from your project like:
find YOUR_SRC_DIR -path '*.tsx' -o -path '*.ts' | wc -l
find YOUR_SRC_DIR -path '*.tsx' -o -path '*.ts' | xargs cat | grep '^import.*\.' | wc -l
find YOUR_SRC_DIR -path '*.tsx' -o -path '*.ts' | xargs cat | grep '^export ' | wc -l
Hi @pzavolinsky Following are the stats that you asked for: Number of TS files: 144 Number of exports: 436
For the number of imports, the command you provided (^import.*\.
) gave a very low number, so I tried another regex: ^import.* from .*
and this seems to give a number more in line with what I'd expect and also very close to what a search in VSCode gave: 924.
I added the changes you mentioned and the output log is 105MB in size. I'll go through it to see if I can find something. In the meantime, I'll also consult with my team if it's okay to share the logs. What I did find interesting is that towards the end, there are multiple files whose otherFiles
come to 30k+ in number. I think that such a large number is indeed a cyclic dependency. I'll run some other tools to see if there are any such and let you know.
Hi @SuhairZain I'm closing this issue. If you are still facing these problems and can provide more info so that we can troubleshoot it together fell free to reopen it.
Hi, While running with our project, the process runs for about 2 minutes and then crashes. The memory consumption of the process goes upto 1.44GB before it crashes. Here's the crash log if it'd help. This is a closed-source project and thus unfortunately I'm unable to share the code.