vuejs / language-tools

⚡ High-performance Vue language tooling based-on Volar.js
https://marketplace.visualstudio.com/items?itemName=Vue.volar
MIT License
5.55k stars 373 forks source link

Extension Throws Exception at Activation in New Component Files #4457

Closed CristopherH95 closed 5 days ago

CristopherH95 commented 2 weeks ago

Vue - Official extension or vue-tsc version

2.0.21

VSCode version

1.90.0

Vue version

3.4.21

TypeScript version

5.4.0

System Info

No response

Steps to reproduce

  1. Create a new project, such as those generated by npm create vue@latest.
  2. Add a devcontainer.json file in a .devcontainer in the root of the project, configured to provide a Node.js and Typescript environment and install the Vue - Official extension.
  3. Reopen the project in the DevContainer.
  4. Install dependencies specified in package.json.
  5. The installed Vue - Official extension appears to work, with IntelliSense running and utilities like "go to definition" working as expected.
  6. Attempt to create a new single file component (e.g., MyTest.vue).
  7. The Vue - Official extension appears to no longer work completely as expected in the new component file (e.g., if importing an existing component, there is no auto-import and "go to definition" does not work).
  8. Observe that the extension now reports uncaught errors during activation.

Link to minimal reproduction

https://github.com/CristopherH95/Vue-Extension-Issue

Any additional comments?

This issue was originally encountered while using Podman with a DevContainer environment for a Vuetify project. This also seemed to occur for me the same in a "vanilla" Vue project such as one in the provided GitHub repo. Upon a quick test, it looks like I also run into this outside of the DevContainer as well.

Examples of errors seen: Screenshot 2024-06-10 090304 Screenshot 2024-06-10 090328

johnsoncodehk commented 1 week ago

The issue of creating a new file seems to be related to #4424. The source code of the thrown error (TypeError: Cannot read properties of undefined (reading 'match')) is https://github.com/volarjs/volar.js/blob/a59765125bb02f1ea62bedd8e3db2a88433538ba/packages/vscode/lib/features/autoInsertion.ts#L63, which is related to auto insertion, I think it's a different issue.

litingyes commented 1 week ago

The issue of creating a new file seems to be related to #4424. The source code of the thrown error (TypeError: Cannot read properties of undefined (reading 'match')) is https://github.com/volarjs/volar.js/blob/a59765125bb02f1ea62bedd8e3db2a88433538ba/packages/vscode/lib/features/autoInsertion.ts#L63, which is related to auto insertion, I think it's a different issue.

so how to avoid the error about Cannot read properties of undefined (reading 'match')

wsndshx commented 6 days ago

我也遇到了相同的问题,当出现该问题时,插件 ts-plugin 的纠错功能将失效,并且会卡住一些任务的线程。 I encountered the same issue. When this problem occurs, the error correction function of the plugin ts-plugin will fail, and it will hang some threads of tasks.

例如格式化功能会需要长达数秒的时间才能完成,git无法检测文件变更等... For example, the formatting function takes several seconds to complete, and Git cannot detect file changes, etc...

image