TL;DR:
I have Cursor (Pro) and the typescript server keeps crashing on me. Investigations revealed that the FileWatcher (according to tsserver.log
) is watching node_modules
!!! Even though jsconfig.json excludes node_modules
in every way possible. (See jsconfig.json
at end)
Details:
I use a monorepo with several inter-dependent top-level folders, as you’ll see in the data below, but not sure that’s relevant or not.
I found the problem from this snippet in the exthost
folder under the typescript extension’s TypeScript.log
file:
TypeScript.log
snippet
2025-01-13 17:35:54.945 [info] <syntax> Forking...
2025-01-13 17:35:54.945 [info] <syntax> Starting...
2025-01-13 17:35:54.945 [info] <semantic> Log file: /Users/josiahbryan/Library/Application Support/Cursor/logs/20250113T165214/window2/exthost/vscode.typescript-language-features/tsserver-semantic-log-3lYcvc/tsserver.log
2025-01-13 17:35:54.945 [info] <semantic> Forking...
2025-01-13 17:35:54.945 [info] <semantic> Starting...
2025-01-13 17:36:22.134 [error] TSServer exited. Code: null. Signal: SIGABRT
2025-01-13 17:36:22.134 [info] TSServer log file: /Users/josiahbryan/Library/Application Support/Cursor/logs/20250113T165214/window2/exthost/vscode.typescript-language-features/tsserver-semantic-log-3lYcvc/tsserver.log
2025-01-13 17:36:22.134 [info] Starting TS Server
Discussion
So at 17:36:22, the server aborts. Okay, so why? So I track down the tsserver.log
mentioned …and here’s a relevant(?) snippet from tsserver.log
- note the log ends at 17:36:18.067 as that’s the last entry in the log, so missing ~4 seconds of logs. I admit I could be chasing the wrong thing, but it DOES seem sus that node_modules shows up so much here. Happy to hare more of the log if it helps.
tsserver.log
snippet
Info 5890 [17:36:17.378] Running: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json
Info 5891 [17:36:17.378] Starting updateGraphWorker: Project: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json
Info 5892 [17:36:17.927] FileWatcher:: Added:: WatchInfo: /Users/josiahbryan/Library/Caches/typescript/5.5/node_modules/@types/eslint/package.json 2000 undefined Project: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json WatchType: File location affecting resolution
Info 5893 [17:36:17.931] FileWatcher:: Added:: WatchInfo: /Users/josiahbryan/Library/Caches/typescript/5.5/node_modules/@types/howler/package.json 2000 undefined Project: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json WatchType: File location affecting resolution
Info 5894 [17:36:17.956] FileWatcher:: Added:: WatchInfo: /Users/josiahbryan/Library/Caches/typescript/5.5/node_modules/@types/three/package.json 2000 undefined Project: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json WatchType: File location affecting resolution
Info 5895 [17:36:18.012] FileWatcher:: Added:: WatchInfo: /Users/josiahbryan/Library/Caches/typescript/5.5/node_modules/@types/webxr/package.json 2000 undefined Project: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json WatchType: File location affecting resolution
Info 5896 [17:36:18.059] FileWatcher:: Added:: WatchInfo: /Users/josiahbryan/devel/rubber/managed-apps/node_modules/autolinker/package.json 2000 undefined Project: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json WatchType: File location affecting resolution
Info 5897 [17:36:18.067] FileWatcher:: Added:: WatchInfo: /Users/josiahbryan/devel/rubber/managed-apps/node_modules/aws-sdk/package.json 2000 undefined Project: /Users/josiahbryan/devel/rubber/managed-apps/jsconfig.json WatchType: File location affecting resolution
Discussion
Note that FileWatcher is admitting it’s watching “managed-apps/node_modules” even though it also says it is using the managed-apps/jsconfig.json
, which is shown below and explicitly EXCLUDES node_modules in every way possible. (I’ve been desperately trying to get this to work, hence all the variations, yet no matter what I do, it seems to include node_modules in the watch list)
jsonconfig.json
Here’s the /managed-apps/jsconfig.json
file that is shown in the logs:
{
"compilerOptions": {
// Helps VS Code resolve imports relative to /src directory
// Essential in monorepos to avoid confusing relative paths (../../)
"baseUrl": ".",
// Prevents deep scanning of node_modules which improves performance
// Particularly important in monorepos with multiple node_modules folders
"maxNodeModuleJsDepth": 0,
// Uses Node.js style module resolution
// Critical for correctly resolving imports between different packages in the monorepo
"moduleResolution": "node",
// Allows cleaner import syntax (import React from 'react' vs import * as React from 'react')
// Maintains consistency across the monorepo, especially when some packages use default exports and others don't
"allowSyntheticDefaultImports": true,
"paths": {
// This fixes the import of shared components that were copied from outside shared into here.
// "toolkit" : ["./toolkit"],
"managed-apps/*": ["./*"],
"backend/*": ["../backend/src/*"],
"shared/*": ["../shared/*"],
"admin-app/*": ["../admin-app/src/*"]
}
},
"include": [
"./toolkit/**/*",
"./**/frontend/*",
"./**/backend/**/*",
"./**/common/*"
],
"exclude": [
"node_modules",
"../shared/node_modules",
"../managed_apps/node_modules",
"../admin-app/node_modules",
"../backend/node_modules",
"**/node_modules",
"./node_modules/**/*",
"**/Caches/**/*",
"**/Library/**/*"
]
}