yarnpkg / berry

📦🐈 Active development trunk for Yarn ⚒
https://yarnpkg.com
BSD 2-Clause "Simplified" License
7.23k stars 1.07k forks source link

[Bug?]: 5.4.5-sdk crashes TypeScript Language Server in VSCode #6304

Closed c-eberling closed 1 month ago

c-eberling commented 1 month ago

Self-service

Describe the bug

Running yarn dlx @yarnpkg/sdks vscode adds the "typescript.tsdk": ".yarn/sdks/typescript/lib" to the settings.json. This uses the workspace Typescript version 5.4.5-sdk which causes a crash:

The JS/TS language service immediately crashed 5 times. The service will not be restarted. with no server logs.

I have restarted the TS Server, disabled all extensions, deleted the repo and recloned, deleted VSCode and reinstalled, restarted my machine, etc.

This person reported identical issue 13 hours ago: https://github.com/microsoft/vscode/issues/213186

To reproduce

Follow these instructions https://yarnpkg.com/getting-started/editor-sdks#vscode Restart VSCode, JS/TS Language service immediately crashes.

Environment

System:
    OS: macOS 14.4.1
    CPU: (12) arm64 Apple M3 Pro
  Binaries:
    Node: 20.10.0 - /private/var/folders/sh/q4dth3396g9frk3r3wcdcbh40000gn/T/xfs-04523905/node
    Yarn: 4.2.2 - /private/var/folders/sh/q4dth3396g9frk3r3wcdcbh40000gn/T/xfs-04523905/yarn
    npm: 10.2.3 - ~/.volta/tools/image/node/20.10.0/bin/npm
    pnpm: 9.1.2 - ~/.volta/bin/pnpm
    bun: 1.0.29 - /opt/homebrew/bin/bun

Additional context

No response

matt-snow-deepsee commented 1 month ago

@c-eberling did you ever get this working? I just reset my computer to factory settings and reinstalled everything, all to get the same error. My coworker has the same setup as far as we can tell and has had no issues.

matt-snow-deepsee commented 1 month ago

@c-eberling we found the solution that worked for us. it's a vscode setting called "typescript.tsserver.experimental.useVsCodeWatcher" that somehow got turned on by default, but didn't show up in the settings.json file. set it to false and reload your window. Hope this helps, and good luck.

mjbvz commented 1 month ago

"typescript.tsserver.experimental.useVsCodeWatcher" that somehow got turned on by default,

VS Code turned this on as a default for all users on TS 5.4+. Since it's a new default, you won't see it in your settings json

For now you can turn the setting off in your user or workspace settings but the root cause is the yarn side and will need to be fixed here


Here's the exception that seems to cause the crash:

Error: Debug Failure. False expression: Should only call `IOSession.prototype.event` on an initialized IOSession
    at fail (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:4010:15)
    at Object.assert (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:4031:7)
    at IpcIOSession.event (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/tsserver.js:497:32)
    at IpcIOSession.defaultEventHandler (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:189322:14)
    at _ProjectService.eventHandler (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:189225:83)
    at getOrCreateFileWatcher (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:184688:15)
    at Object.watchFile2 [as watchFile] (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:184657:12)
    at watchFile (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:122785:67)
    at Object.watchFile (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:122854:92)
    at createFileWatcherWithLogging (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:122827:44)
    at Object.watchFile (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:122804:283)
    at _ProjectService.watchPnpFile (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:187802:30)
    at new _ProjectService (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:184865:28)
    at new _Session (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/typescript.js:189254:27)
    at new IOSession (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/tsserver.js:471:7)
    at new IpcIOSession (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/tsserver.js:533:3)
    at startNodeSession (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/tsserver.js:570:34)
    at start (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/tsserver.js:630:3)
    at Object.<anonymous> (/Users/matb/projects/sandbox/.yarn/cache/typescript-patch-e22b0fdb7a-30879da4f4.zip/node_modules/typescript/lib/tsserver.js:647:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
    at require$$0.Module._extensions..js (/Users/matb/projects/sandbox/.pnp.cjs:8890:33)
    at Module.load (node:internal/modules/cjs/loader:1098:32)
    at Module._load (node:internal/modules/cjs/loader:945:12)
    at c._load (node:electron/js2c/node_init:2:13672)
    at require$$0.Module._load (/Users/matb/projects/sandbox/.pnp.cjs:8735:31)
    at Module.require (node:internal/modules/cjs/loader:1122:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (/Users/matb/projects/sandbox/.yarn/sdks/typescript/lib/tsserver.js:232:32)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
    at Module.load (node:internal/modules/cjs/loader:1098:32)
    at Module._load (node:internal/modules/cjs/loader:945:12)
    at c._load (node:electron/js2c/node_init:2:13672)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:96:12)
    at node:internal/main/run_main_module:23:47'
clemyan commented 1 month ago

This is a duplicate of #6270. For the time being, you can use "typescript.tsserver.experimental.useVsCodeWatcher": false to work around this.