I don’t know why but my TypeScript server is using all of my CPU and then it crashes. My guess is it’s also handling files inside the node_modules folder, because when I delete the node_modules folder. the npx tsc --listFiles command works fine. But with the node_modules folder it gets stuck using all of my CPU then it throws javascript heap out of memory error.
Check this output
napstar@KHAN-PC:~/dev/imgDrive$ tsc --listFiles
<--- Last few GCs --->
[11058:0x2be67000] 108760 ms: Scavenge (interleaved) 2042.7 (2083.8) -> 2041.0 (2087.8) MB, pooled: 0 MB, 3.51 / 0.00 ms (average mu = 0.088, current mu = 0.011) allocation failure;
[11058:0x2be67000] 109124 ms: Mark-Compact (reduce) 2044.9 (2088.3) -> 2043.0 (2083.1) MB, pooled: 0 MB, 288.53 / 0.00 ms (+ 15.9 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 325 ms) (average mu = 0.210, cu
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----
1: 0xe16044 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node]
2: 0x11e0dd0 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
3: 0x11e10a7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
4: 0x140e985 [node]
5: 0x140e9b3 [node]
6: 0x1427a8a [node]
7: 0x142ac58 [node]
8: 0x1c90921 [node]
Aborted (core dumped)
napstar@KHAN-PC:~/dev/imgDrive$
For context I am using pnpm as package manager, my app is in Next.js, below is my tsconfig.json
// tsconfig.json
{
"compilerOptions": {
"target": "ES2017",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
}
},
"include": [
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"next-env.d.ts",
"build/types/**/*.ts"
],
"exclude": [
"node_modules",
"build",
".next"
]
}
I enabled server logs for TypeScript in VS Code, and this what I got
napstar@KHAN-PC:~/dev/imgDrive$ cat /home/napstar/.vscode-server/data/logs/20250717T114015/exthost2/vscode.typescript-language-features/tsserver-log-pKGsVY/tsserver.log
Info 0 [12:08:54.048] Starting TS Server
Info 1 [12:08:54.048] Version: 5.8.3
Info 2 [12:08:54.048] Arguments: /home/napstar/.vscode-server/bin/7adae6a56e34cb64d08899664b814cf620465925/node /home/napstar/dev/imgDrive/node_modules/typescript/lib/tsserver.js --useInferredProjectPerProjectRoot --disableAutomaticTypingAcquisition --cancellationPipeName /tmp/vscode-typescript1000/b2b07718e2cd64fe9b66/tscancellation-26973b6f1cbad88ad3e1.tmp* --logVerbosity normal --logFile /home/napstar/.vscode-server/data/logs/20250717T114015/exthost2/vscode.typescript-language-features/tsserver-log-pKGsVY/tsserver.log --traceDirectory "/home/napstar/.vscode-server/data/logs/20250717T114015/exthost2/vscode.typescript-language-features/tsserver-log-jtTbtJ" --locale en --noGetErrOnBackgroundUpdate --canUseWatchEvents --validateDefaultNpmLocation --useNodeIpc
Info 3 [12:08:54.048] Platform: linux NodeVersion: v22.15.1 CaseSensitive: true
Info 4 [12:08:54.048] ServerMode: undefined hasUnknownServerMode: undefined
Info 5 [12:08:54.054] currentDirectory:: /mnt/c/Users/zohai/AppData/Local/Programs/Microsoft VS Code useCaseSensitiveFileNames:: true
Info 6 [12:08:54.054] libs Location:: /home/napstar/dev/imgDrive/node_modules/.pnpm/[email protected]/node_modules/typescript/lib
Info 7 [12:08:54.054] globalTypingsCacheLocation:: undefined
Info 8 [12:08:54.057] Host information vscode
Info 9 [12:08:54.059] getConfigFileNameForFile:: File: /home/napstar/dev/imgDrive/app/account/images/edit-dialog-control.tsx ProjectRootPath: /home/napstar/dev/imgDrive:: Result: /home/napstar/dev/imgDrive/tsconfig.json
Info 10 [12:08:54.060] Creating ConfiguredProject: /home/napstar/dev/imgDrive/tsconfig.json, currentDirectory: /home/napstar/dev/imgDrive
Info 11 [12:08:54.094] Config: /home/napstar/dev/imgDrive/tsconfig.json : {
"rootNames": [
"/home/napstar/dev/imgDrive/actions.ts",
"/home/napstar/dev/imgDrive/auth.ts",
"/home/napstar/dev/imgDrive/drizzle.config.ts",
"/home/napstar/dev/imgDrive/jest.config.ts",
"/home/napstar/dev/imgDrive/jest.polyfill.ts",
"/home/napstar/dev/imgDrive/jest.setup.ts",
"/home/napstar/dev/imgDrive/middleware.ts",
"/home/napstar/dev/imgDrive/next-env.d.ts",
"/home/napstar/dev/imgDrive/next.config.ts",
"/home/napstar/dev/imgDrive/__mocks__/server.ts",
"/home/napstar/dev/imgDrive/app/api/auth/[...nextauth]/route.ts",
"/home/napstar/dev/imgDrive/app/api/images/handle-request.ts",
"/home/napstar/dev/imgDrive/app/api/images/route.ts",
"/home/napstar/dev/imgDrive/app/api/images/[id]/route.ts",
"/home/napstar/dev/imgDrive/app/api/images/__tests__/handle-requests.test.ts",
"/home/napstar/dev/imgDrive/app/api/images/__tests__/route.test.ts",
"/home/napstar/dev/imgDrive/app/i/[id]/route.ts",
"/home/napstar/dev/imgDrive/config/index.ts",
"/home/napstar/dev/imgDrive/hooks/use-drive-uploader.ts",
"/home/napstar/dev/imgDrive/hooks/use-mobile.ts",
"/home/napstar/dev/imgDrive/hooks/__tests__/use-drive-uploader.test.ts",
"/home/napstar/dev/imgDrive/lib/drive.ts",
"/home/napstar/dev/imgDrive/lib/helpers.ts",
"/home/napstar/dev/imgDrive/lib/rate-limiter.ts",
"/home/napstar/dev/imgDrive/lib/redis.ts",
"/home/napstar/dev/imgDrive/lib/utils.ts",
"/home/napstar/dev/imgDrive/lib/db/index.ts",
"/home/napstar/dev/imgDrive/lib/db/schema.ts",
"/home/napstar/dev/imgDrive/lib/db/repositories/accounts.ts",
"/home/napstar/dev/imgDrive/lib/db/repositories/api-key-logs.ts",
"/home/napstar/dev/imgDrive/lib/db/repositories/api-keys.ts",
"/home/napstar/dev/imgDrive/lib/db/repositories/images.ts",
"/home/napstar/dev/imgDrive/lib/middleware/authenticate-api-key.ts",
"/home/napstar/dev/imgDrive/lib/schemas/forms.ts",
"/home/napstar/dev/imgDrive/types/index.ts",
"/home/napstar/dev/imgDrive/types/next-auth.d.ts",
"/home/napstar/dev/imgDrive/app/layout.tsx",
"/home/napstar/dev/imgDrive/app/not-found.tsx",
"/home/napstar/dev/imgDrive/app/page.tsx",
"/home/napstar/dev/imgDrive/app/account/layout.tsx",
"/home/napstar/dev/imgDrive/app/account/not-found.tsx",
"/home/napstar/dev/imgDrive/app/account/page.tsx",
"/home/napstar/dev/imgDrive/app/account/(upload)/layout.tsx",
"/home/napstar/dev/imgDrive/app/account/(upload)/upload/images-input.tsx",
"/home/napstar/dev/imgDrive/app/account/(upload)/upload/images-list.tsx",
"/home/napstar/dev/imgDrive/app/account/(upload)/upload/page.tsx",
"/home/napstar/dev/imgDrive/app/account/[...slug]/page.tsx",
"/home/napstar/dev/imgDrive/app/account/api-keys/columns.tsx",
"/home/napstar/dev/imgDrive/app/account/api-keys/copy-api-key-dialog.tsx",
"/home/napstar/dev/imgDrive/app/account/api-keys/create-api-key-dialog.tsx",
"/home/napstar/dev/imgDrive/app/account/api-keys/data-table.tsx",
"/home/napstar/dev/imgDrive/app/account/api-keys/page.tsx",
"/home/napstar/dev/imgDrive/app/account/api-keys/revoke-api-key-alert.tsx",
"/home/napstar/dev/imgDrive/app/account/images/delete-alert.tsx",
"/home/napstar/dev/imgDrive/app/account/images/edit-dialog-control.tsx",
"/home/napstar/dev/imgDrive/app/account/images/edit-dialog.tsx",
"/home/napstar/dev/imgDrive/app/account/images/grid-view-active-image-sheet.tsx",
"/home/napstar/dev/imgDrive/app/account/images/grid-view-image.tsx",
"/home/napstar/dev/imgDrive/app/account/images/grid-view-selected-header.tsx",
"/home/napstar/dev/imgDrive/app/account/images/grid-view.tsx",
"/home/napstar/dev/imgDrive/app/account/images/img-element.tsx",
"/home/napstar/dev/imgDrive/app/account/images/page.tsx",
"/home/napstar/dev/imgDrive/app/account/images/share-dialog.tsx",
"/home/napstar/dev/imgDrive/app/account/images/table-view.tsx",
"/home/napstar/dev/imgDrive/app/signin/page.tsx",
"/home/napstar/dev/imgDrive/components/account-header.tsx",
"/home/napstar/dev/imgDrive/components/account-nav-main.tsx",
"/home/napstar/dev/imgDrive/components/account-nav-user.tsx",
"/home/napstar/dev/imgDrive/components/account-sidebar.tsx",
"/home/napstar/dev/imgDrive/components/async-alert.tsx",
"/home/napstar/dev/imgDrive/components/copy-button.tsx",
"/home/napstar/dev/imgDrive/components/date-picker.tsx",
"/home/napstar/dev/imgDrive/components/footer.tsx",
"/home/napstar/dev/imgDrive/components/header.tsx",
"/home/napstar/dev/imgDrive/components/image-options-form.tsx",
"/home/napstar/dev/imgDrive/components/mode-switcher.tsx",
"/home/napstar/dev/imgDrive/components/multi-select.tsx",
"/home/napstar/dev/imgDrive/components/session-provider.tsx",
"/home/napstar/dev/imgDrive/components/sign-in.tsx",
"/home/napstar/dev/imgDrive/components/sign-out.tsx",
"/home/napstar/dev/imgDrive/components/theme-provider.tsx",
"/home/napstar/dev/imgDrive/components/ui/alert-dialog.tsx",
"/home/napstar/dev/imgDrive/components/ui/aspect-ratio.tsx",
"/home/napstar/dev/imgDrive/components/ui/avatar.tsx",
"/home/napstar/dev/imgDrive/components/ui/badge.tsx",
"/home/napstar/dev/imgDrive/components/ui/button.tsx",
"/home/napstar/dev/imgDrive/components/ui/calendar.tsx",
"/home/napstar/dev/imgDrive/components/ui/card.tsx",
"/home/napstar/dev/imgDrive/components/ui/command.tsx",
"/home/napstar/dev/imgDrive/components/ui/dialog.tsx",
"/home/napstar/dev/imgDrive/components/ui/dropdown-menu.tsx",
"/home/napstar/dev/imgDrive/components/ui/form.tsx",
"/home/napstar/dev/imgDrive/components/ui/input.tsx",
"/home/napstar/dev/imgDrive/components/ui/label.tsx",
"/home/napstar/dev/imgDrive/components/ui/popover.tsx",
"/home/napstar/dev/imgDrive/components/ui/progress.tsx",
"/home/napstar/dev/imgDrive/components/ui/separator.tsx",
"/home/napstar/dev/imgDrive/components/ui/sheet.tsx",
"/home/napstar/dev/imgDrive/components/ui/sidebar.tsx",
"/home/napstar/dev/imgDrive/components/ui/skeleton.tsx",
"/home/napstar/dev/imgDrive/components/ui/sonner.tsx",
"/home/napstar/dev/imgDrive/components/ui/switch.tsx",
"/home/napstar/dev/imgDrive/components/ui/table.tsx",
"/home/napstar/dev/imgDrive/components/ui/tabs.tsx",
"/home/napstar/dev/imgDrive/components/ui/textarea.tsx",
"/home/napstar/dev/imgDrive/components/ui/tooltip.tsx",
"/home/napstar/dev/imgDrive/components/ui/kibo-ui/image-zoom/index.tsx",
"/home/napstar/dev/imgDrive/hooks/use-meta-color.tsx"
],
"options": {
"target": 4,
"lib": [
"lib.dom.d.ts",
"lib.dom.iterable.d.ts",
"lib.esnext.d.ts"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"module": 99,
"moduleResolution": 100,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": 1,
"incremental": true,
"plugins": [
{
"name": "next"
}
],
"paths": {
"@/*": [
"./*"
]
},
"pathsBasePath": "/home/napstar/dev/imgDrive",
"configFilePath": "/home/napstar/dev/imgDrive/tsconfig.json"
}
}
Info 12 [12:08:54.096] Enabling plugin next from candidate paths: /home/napstar/dev/imgDrive/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js/../../..
Info 13 [12:08:54.096] Loading next from /home/napstar/dev/imgDrive/node_modules/.pnpm/[email protected]/node_modules/typescript/lib/typescript.js/../../.. (resolved to /home/napstar/dev/imgDrive/node_modules/.pnpm/[email protected]/node_modules/node_modules)
Info 14 [12:08:54.186] [next] Initializing Next.js TypeScript plugin: /home/napstar/dev/imgDrive
Info 15 [12:08:54.208] [next] Successfully initialized Next.js TypeScript plugin!
Info 16 [12:08:54.208] Plugin validation succeeded
Info 17 [12:08:54.219] Starting updateGraphWorker: Project: /home/napstar/dev/imgDrive/tsconfig.json
Info 18 [12:09:10.513] Finishing updateGraphWorker: Project: /home/napstar/dev/imgDrive/tsconfig.json projectStateVersion: 1 projectProgramVersion: 0 structureChanged: true structureIsReused:: Not Elapsed: 15212.420032ms
Info 19 [12:09:10.513] Project '/home/napstar/dev/imgDrive/tsconfig.json' (Configured)
Info 20 [12:09:10.513] Files (8926)
Info 21 [12:09:10.514] -----------------------------------------------
Info 22 [12:09:10.627] AutoImportProviderProject: attempted to add more than 10 dependencies. Aborting.
Info 23 [12:09:10.659] getConfigFileNameForFile:: File: /home/napstar/dev/imgDrive/app/account/images/edit-dialog.tsx ProjectRootPath: /home/napstar/dev/imgDrive:: Result: /home/napstar/dev/imgDrive/tsconfig.json
Info 24 [12:09:10.670] Project '/home/napstar/dev/imgDrive/tsconfig.json' (Configured)
Info 24 [12:09:10.671] Files (8926)
Info 24 [12:09:10.671] -----------------------------------------------
Info 24 [12:09:10.671] Open files:
Info 24 [12:09:10.671] FileName: /home/napstar/dev/imgDrive/app/account/images/edit-dialog-control.tsx ProjectRootPath: /home/napstar/dev/imgDrive
Info 24 [12:09:10.671] Projects: /home/napstar/dev/imgDrive/tsconfig.json
Info 24 [12:09:10.671] FileName: /home/napstar/dev/imgDrive/app/account/images/edit-dialog.tsx ProjectRootPath: /home/napstar/dev/imgDrive
Info 24 [12:09:10.671] Projects: /home/napstar/dev/imgDrive/tsconfig.json
napstar@KHAN-PC:~/dev/imgDrive$
Every file loads, Next plugin loads successfully, but then I think updateGraphWorker throw some error and it says 8926 files. I don’t have 8926 files in my project