Skip to content

Conversation

@ottenhoff
Copy link

Fix system crash (OOM) caused by updater spending time in folders like docs/

  • Skip hidden and vendor directories (node_modules, vendor, docs, etc.) to avoid OOM
  • free ASTs immediately
  • ts-morph dependency bumped to ^27.0.2

…en/large dirs (node_modules, vendor, docs, etc.) to avoid OOMs and hangs; frees ASTs immediately.

- ts-morph dependency bumped to ^27.0.2.
Comment on lines 181 to 193
let totalFiles = 0;
let userFileCount = 0;
for await (
const entry of walk(dir, {
includeDirs: false,
includeFiles: true,
exts: ["js", "jsx", "ts", "tsx"],
skip: [SKIP_DIRS],
})
) {
totalFiles++;
if (!HIDE_FILES.test(entry.path)) userFileCount++;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's store the found paths, so that we don't need to walk the file system again a second time.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I just pushed a new commit.

const HIDE_FILES = /[\\/]+(node_modules|vendor)[\\/]+/;
// Directories we should completely skip when walking the tree. This keeps us
// from loading vendored dependencies (often thousands of files) into ts-morph.
const SKIP_DIRS =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between HIDE_FILES and SKIP_DIRS? Aren't both used for the same thing? Let's unify that.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants