typed-ember / glint

TypeScript powered tooling for Glimmer templates
https://typed-ember.gitbook.io/glint
MIT License
109 stars 51 forks source link

VSCode unable to start Glint language server for… #662

Closed andrewtimberlake closed 8 months ago

andrewtimberlake commented 8 months ago

I’m getting the following error on every file I try to open in VSCode.

Unable to start Glint language service for /Users/andrew/dev/bbff/editor/app/services/song-player.ts. TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Array at new NodeError (node:internal/errors:399:5) at validateString (node:internal/validators:163:11) at Module.resolve (node:path:1092:7) at loadConfigInput (file:///Users/andrew/dev/bbff/editor/node_modules/@glint/core/lib/config/loader.js:60:45) at ConfigLoader.configForDirectory (file:///Users/andrew/dev/bbff/editor/node_modules/@glint/core/lib/config/loader.js:29:27) at ConfigLoader.configForFile (file:///Users/andrew/dev/bbff/editor/node_modules/@glint/core/lib/config/loader.js:17:21) at LanguageServerPool.configForURI (file:///Users/andrew/dev/bbff/editor/node_modules/@glint/core/lib/language-server/pool.js:38:34) at LanguageServerPool.getServerDetailsForURI (file:///Users/andrew/dev/bbff/editor/node_modules/@glint/core/lib/language-server/pool....

I think this output in Extension host is related:

[error] Error: ENOENT: no such file or directory, open 'exthost'
    at Object.openSync (node:fs:603:3)
    at Object.func [as openSync] (node:electron/js2c/asar_bundle:2:1869)
    at Object.readFileSync (node:fs:471:35)
    at Object.t.readFileSync (node:electron/js2c/asar_bundle:2:9212)
    at TWSController.<anonymous> (/Users/andrew/.vscode/extensions/jkiviluoto.tws-1.0.1/out/extension.js:63:32)
    at n.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
    at n.z (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1972)
    at n.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2188)
    at f.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:145:16612)
    at n.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
    at n.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2119)
    at i.acceptDocumentsAndEditorsDelta (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:12599)
    at i.$acceptDocumentsAndEditorsDelta (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:143:10970)
    at l.S (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:10829)
    at l.Q (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:10595)
    at l.M (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:9685)
    at l.L (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:8764)
    at f.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:150:7567)
    at n.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
    at n.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2119)
    at o.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:103:14039)
    at f.value (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:171:7903)
    at n.y (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:1902)
    at n.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:80:2119)
    at o.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:103:14039)
    at MessagePortMain.<anonymous> (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/api/node/extensionHostProcess.js:171:6183)
    at MessagePortMain.emit (node:events:513:28)
    at Object.MessagePortMain._internalPort.emit (node:electron/js2c/utility_init:2:367)

This is a new project, Ember 5.5 with ember template imports and no extra addons, running on Node 20.10.0

NullVoxPopuli commented 8 months ago

Glint is only compatible with ember-template-imports v3, until this is released:

What version of these deps do you have?

andrewtimberlake commented 8 months ago

Thanks

It was: ember-template-imports 4.0.0 @glint/core 1.2.1

It seems this has removed the error: ember-template-imports 3.4.2 @glint/core 1.1.0 (1.2.0 didn’t work)

NullVoxPopuli commented 8 months ago

Which dep change resolved the error?

Can you try upgrading glint, using ember-template-imports v3?

lifeart commented 8 months ago

According to stack trace issue related to https://marketplace.visualstudio.com/items?itemName=jkiviluoto.tws (/extensions/jkiviluoto.tws-1.0.1), not glint

andrewtimberlake commented 8 months ago

Which dep change resolved the error?

Can you try upgrading glint, using ember-template-imports v3?

If I upgrade to Glint 1.2.0, I get the following in the output:

file:///Users/andrew/dev/bbff/editor/node_modules/@glint/core/lib/language-server/util/index.js:3
import VSCodeURI from 'vscode-uri';
       ^^^^^^^^^
SyntaxError: The requested module 'vscode-uri' does not provide an export named 'default'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

Node.js v18.15.0
[Info  - 10:58:36] Connection to server got closed. Server will restart.
[Error - 10:58:36] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 10:58:36] Glint client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 

If I upgrade to @glint/core 1.2.1 then I return to the original error “Unable to start Glint language server…”

andrewtimberlake commented 8 months ago

I installed a new project with just ember-template-imports (3.4.2) and glint (1.2.1) and it worked. I then found a difference in my tsconfig.json file and changed that, now my current project has Glint working at 1.2.1 with ember-template-imports at 3.4.2 Thanks!

NullVoxPopuli commented 8 months ago

What did you change in your tsconfig.json that made things work?

andrewtimberlake commented 8 months ago

Here’s the diff CleanShot 2024-01-03 at 15 43 32@2x

NullVoxPopuli commented 8 months ago

There are a few things going on there

  1. Murtiple extends - does one of your tools not support this? Does glint not support multiple extends somehow?
  2. Required glint imports moved to grobals.d.ts, nice.
  3. Includes in tsconfig removed, are you still type checking? Or now type checking too much?
andrewtimberlake commented 8 months ago

Thanks for pursuing this. I just wanted to get it to work, so the moment I got something without errors, I stopped. I have now isolated it to multiple extends. The moment I change tsconfig.json to:

{
  "extends": ["@tsconfig/ember/tsconfig.json"],

I get the “Unable to start Glint language server…” error.

The diff now looks like this: CleanShot 2024-01-03 at 16 12 31@2x

NullVoxPopuli commented 8 months ago

Legit, thanks!, can you open a separate issue for supporting multiple extends?

dfreeman commented 8 months ago

Does TS itself support multiple extends? I don't see that documented https://www.typescriptlang.org/tsconfig#extends

andrewtimberlake commented 8 months ago

It may not. I don’t remember how I got to that in my original config. I don’t think I need it so I’ll leave this here.

NullVoxPopuli commented 8 months ago

Does TS itself support multiple extends

it does, it's the whole reason the @tsconfig/bases repo has migrated to the setup that it has. You can extend multiple now, as of TS 5

As is common, documentation is incomplete, and not the source of truth :upside_down_face:

achambers commented 8 months ago

Hi folks. Just came across this as I'm experiencing it too. Just wanted to add a slight bit of colour as I don't see the exact solution here.

I have a new ember app as of last week (Ember v5.5.0) and all the deps that brings with it.

"ember-template-imports": "^4.0.0",
"@glint/core": "^1.2.2",

I can confirm that the issue was due to the multiple extends. So the following changed fixed it:

-  "extends": [
-    "@tsconfig/strictest/tsconfig.json",
-    "@tsconfig/ember/tsconfig.json"
-  ],
+  "extends": "@tsconfig/ember/tsconfig.json"

Now, the bit that I didn't see here is why "@tsconfig/strictest/tsconfig.json" existed and how we can continue to use it. So, turns out the docs suggest adding that extends in typescript/additional-resources/faq/#toc_strictness.

So, are we saying that we shouldn't be doing that at all and need to change the docs? Or, is there some other way that this should work that I'm missing?

NullVoxPopuli commented 8 months ago

are we saying that we shouldn't be doing that at all and need to change the docs?

glint needs to support this. It's a feature of ts 5.0 :)

andrewtimberlake commented 8 months ago

I’ve opened a separate issue #672