Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode enters into "Initializing JS/TS Language Services" loop in our repo #53574

Closed
hasanayan opened this issue Mar 28, 2023 · 3 comments
Closed
Labels
Needs More Info The issue still hasn't been fully clarified

Comments

@hasanayan
Copy link

hasanayan commented Mar 28, 2023

vscode enters into "Initializing JS/TS Language Services" loop in our repo and this slows things down and I am reloading the window or restarting the TS server every 15 minutes or so

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.76.2
  • OS Version: MacOS 13.2.1

Steps to Reproduce:

Unfortunately, it is not possible to provide a way for you to reproduce this issue as it requires a big monorepo as we have and I can't share our repo as it would mean exposing the client's IP.

However, I'd be more than happy to share non IP info on our repo that would lead us to find the cause of this issue. Here is some initial info;

  • We have a monorepo managed by Nx with ~45 libraries in it
  • We are not using the default typescript config that comes with Nx because we had to implement TS Project References to speed up type checking
  • Almost all of our libs are also using project references to separate the actual source files and test files so that our spec files has jest type included

Here is our tsconfig files;

<repo-root>/tsconfig.base.json: this file includes the base settings, the other tsconfig files extend this config file.

  "compileOnSave": false,
  "compilerOptions": {
    "allowJs": true,
    "outDir": "tsc-out",
    "allowSyntheticDefaultImports": true,
    "allowUnreachableCode": false,
    "allowUnusedLabels": false,
    "baseUrl": ".",
    "composite": true,
    "declaration": true,
    "declarationMap": true,
    "disableSourceOfProjectReferenceRedirect": false,
    "emitDeclarationOnly": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "experimentalDecorators": true,
    "forceConsistentCasingInFileNames": true,
    "importHelpers": true,
    "incremental": true,
    "jsx": "react-jsx",
    "lib": ["dom", "dom.iterable", "esnext"],
    "module": "esnext",
    "moduleResolution": "node",
    "noEmit": false,
    "noEmitOnError": false,
    "noFallthroughCasesInSwitch": true,
    "noImplicitOverride": true,
    "noImplicitReturns": true,
    "noPropertyAccessFromIndexSignature": false,
    "resolveJsonModule": true,
    "rootDir": ".",
    "skipDefaultLibCheck": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "strict": true,
    "target": "esnext",
    "types": ["node"],
    "useUnknownInCatchVariables": false,
    "paths": {
      ....
    }
  },
  "exclude": ["node_modules", "tmp", "tsc-out", "dist"]
}

<repo-root>/tsconfig.json: this is the root tsconfig file that extends tsconfig.base.json and references the lib tsconfig files

  "compilerOptions": { "module": "CommonJS" },
  "extends": "./tsconfig.base.json",
  "files": ["jest.config.ts", "jest.preset.js"],
  "references": [
    ....
  ]
}

in each library we have;

<library-root>/tsconfig.json: extends tsconfig.base.json and references <library-root>/tsconfig.json and <library-root>/tsconfig.spec.json and sometimes tsconfig file in the /.storybook folder

{
  "extends": "../../tsconfig.base.json",
  "files": [],
  "references": [
    {
      "path": "./tsconfig.lib.json"
    },
    {
      "path": "./tsconfig.spec.json"
    },
    {
      "path": "./.storybook"
    }
  ]
}

<library-root>/tsconfig.lib.json: includes the actual source files and excludes the files that are supposed to be included by other tsconfig.json files within the library

{
  "exclude": [
    "src/**/*.spec.ts",
    "src/**/*.test.ts",
    "src/**/*.spec.tsx",
    "src/**/*.test.tsx",
    "src/jest-setup.ts",
    "jest.config.ts",
    "src/test-utils/**/*.ts",
    "src/test-utils/**/*.tsx",
    "src/**/*.mdx"
  ],
  "extends": "./tsconfig.json",
  "files": [
    "../../node_modules/@nrwl/react/typings/image.d.ts",
    "../../libs/ui-theme/src/typings/styled.d.ts"
  ],
  "include": ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"],
  "references": [
 ...
  ]
}

<library-root>/tsconfig.spec.json: includes the test files and excludes the files that are supposed to be included by the other tsconfig.json files within the library

{
  "compilerOptions": {
    "module": "commonjs",
    "types": ["jest", "@testing-library/jest-dom", "node"]
  },
  "extends": "./tsconfig.json",
  "include": [
    "jest.config.ts",
    "src/jest-setup.ts",
    "src/**/*.test.ts",
    "src/**/*.spec.ts",
    "src/**/*.test.tsx",
    "src/**/*.spec.tsx",
    "src/**/*.d.ts",
    "src/test-utils/**/*.ts",
    "src/test-utils/**/*.tsx",
    "assets/**/*.json"
  ],
  "references": [
    {
      "path": "./tsconfig.lib.json"
    }
  ]
}

If you wish to see some diagnostic outputs or logs, please direct me to them so I can share them with you

@hasanayan hasanayan changed the title vscdoe enters into "Initializing JS/TS Language Services" loop in our repo vscode enters into "Initializing JS/TS Language Services" loop in our repo Mar 28, 2023
@hasanayan
Copy link
Author

hasanayan commented Mar 28, 2023

I tried the insider build (1.77.0-insider) with all extensions disabled now;

when I open a JS file it enters "the loop". The loop eats up the memory

VS Code version: Code - Insiders 1.77.0-insider (b9226e1ccc11625bcb42b55efb795e07ee533bb0, 2023-03-24T18:37:48.499Z)
OS version: Darwin arm64 22.3.0
Modes:
Sandboxed: Yes

System Info
Item Value
CPUs Apple M1 Pro (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) 3, 3, 3
Memory (System) 32.00GB (1.93GB free)
Process Argv
Screen Reader yes
VM 0%
Extensions: none
A/B Experiments
vsliv695:30137379
vsins829:30139715
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
pythonvspyl392:30422396
pythontb:30258533
vsc_aa:30263845
pythonptprofiler:30281269
vshan820:30294714
pythondataviewer:30285072
vscod805cf:30301675
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593cf:30376535
pythonvs932:30404738
cppdebug:30492333
vscaat:30438846
vsclangdf:30492506
c4g48928:30535728
dsvsc012:30540252
pynewext54:30618038
pylantcb52:30590116
pyindex848:30611229
nodejswelcome1:30587009
pyind779:30611226
pythonsymbol12:30651887
2i9eh265:30646982
showlangstatbar:30659908
pythonb192cf:30661257
functionswalk:30687959
pythonms35:30671666
03d35959:30680466
57b77579:30687741
pythonclientmv:30689206

@mjbvz mjbvz transferred this issue from microsoft/vscode Mar 29, 2023
@mjbvz mjbvz removed their assignment Mar 29, 2023
@mjbvz
Copy link
Contributor

mjbvz commented Apr 4, 2023

Please try collecting the TS Server log:

  1. Set "typescript.tsserver.log": "verbose",
  2. Restart VS Code and reproduce the problem
  3. In VS Code, run the TypeScript: Open TS Server log command
  4. This should open a large log file called tsserver.log

Look through that log file for errors or stack traces. If you can share the log, I can also take a look to see if anything stands out

⚠️Warning: The TypeScript log may include information from your workspace, including file paths and source code. If you have any concerns about posting this publicly on Github, just let me know and we can arrange something else. On our side, we only use these logs to investigate issues like this

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Apr 7, 2023
@hasanayan
Copy link
Author

thanks, I am enabling the verbose logging and will provide the output

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs More Info The issue still hasn't been fully clarified
Projects
None yet
Development

No branches or pull requests

3 participants