Skip to content
New issue

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

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

Already on GitHub? # to your account

v 0.2.0 broken on windows 11 vscode 1.94.2, unlimited loading or stuck #23

Closed
5 of 7 tasks
dickofn opened this issue Oct 29, 2024 · 26 comments
Closed
5 of 7 tasks

Comments

@dickofn
Copy link

dickofn commented Oct 29, 2024

Describe the bug

  1. you jump (ctrl+click) to a custom component,
  2. works just fine,
  3. close that tab,
  4. jump to the same component

Now there is a loading bar moving just below the tab, everything looks just fine.
But nope, IntelliSense is not working after that

Reproduction

go to a component, close, go to same component again

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 8.92 GB / 31.93 GB
  Binaries:
    Node: 20.11.0 - ~\AppData\Local\fnm_multishells\40828_1730177969014\node.EXE
    Yarn: 1.22.21 - ~\AppData\Local\fnm_multishells\40828_1730177969014\yarn.CMD
    npm: 10.2.4 - ~\AppData\Local\fnm_multishells\40828_1730177969014\npm.CMD
    pnpm: 8.14.1 - ~\AppData\Local\fnm_multishells\40828_1730177969014\pnpm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.74)
    Internet Explorer: 11.0.22621.3527

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributions

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests (actually just go ahead and do it, thanks!)
@rylanharper
Copy link

^^ Same on Mac OS for this. Had to uninstall the plugin 😢

@dickofn
Copy link
Author

dickofn commented Oct 29, 2024

^^ Same on Mac OS for this. Had to uninstall the plugin 😢

@rylanharper for now you can just choose "Install another version" options when clicking gear icon, and pick 0.18.0

@antfu
Copy link
Owner

antfu commented Oct 30, 2024

Can anyone share a reproduction?

/cc @Donovan-Ye are you aware of this? Could you help to take a look? Thank you

@cheny-github
Copy link

I got same problem too

1 similar comment
@arcovery
Copy link

I got same problem too

@Donovan-Ye
Copy link
Contributor

Can anyone share a reproduction?

/cc @Donovan-Ye are you aware of this? Could you help to take a look? Thank you

👌 I am looking at this issue now.

@Donovan-Ye
Copy link
Contributor

@rylanharper Could you please provide a minimal reproduction in MacOS? I am unable to replicate this issue on my Mac with MacOS 14.2 and VSCode 1.95.0. I will attempt to downgrade my VSCode version to resolve it.

@Donovan-Ye
Copy link
Contributor

@rylanharper Could you please provide a minimal reproduction in MacOS? I am unable to replicate this issue on my Mac with MacOS 14.2 and VSCode 1.95.0. I will attempt to downgrade my VSCode version to resolve it.

After downgrading vscode to version 1.94.2 on my macOS, I am still unable to reproduce the issue with plugin v0.2.0 and vitesse...

@dickofn
Copy link
Author

dickofn commented Oct 31, 2024

Fyi I'm using nuxt 3, but currently on holiday, not with my machine

@Donovan-Ye
Copy link
Contributor

I will try again later with more complex projects.

@rylanharper
Copy link

rylanharper commented Oct 31, 2024

For some reason, now that I have re-installed the plugin, I'm not getting the unlimited loading like I was (even though I'm working on the same project).. Trying to replicate this again..

Also, what do you need for a reproduction with a vscode plugin? I've only ever had to create reproductions via Stackblitz before.

@Donovan-Ye
Copy link
Contributor

After trying several times, I discovered that when I reload VSCode and use command+click to go to the definition, it sometimes shows "loading progress" under the tab. This happens because TypeScript needs time to resolve the code in my cases. But rarely encountered.

For the minimal reproduction, I think which is the simplest code that consistently triggers the bug.

@dtrongphuc
Copy link

Same on my Mac

@Donovan-Ye
Copy link
Contributor

Same on my Mac

@dtrongphuc Can you find which plugin or process is loading? and you can try reinstalling the plugin to see if that fixes it.

@dickofn
Copy link
Author

dickofn commented Nov 4, 2024

After trying several times, I discovered that when I reload VSCode and use command+click to go to the definition, it sometimes shows "loading progress" under the tab. This happens because TypeScript needs time to resolve the code in my cases. But rarely encountered.

For the minimal reproduction, I think which is the simplest code that consistently triggers the bug.

I can somewhat confirm this since, my project is right now considerably minimal

@Donovan-Ye
Copy link
Contributor

After trying several times, I discovered that when I reload VSCode and use command+click to go to the definition, it sometimes shows "loading progress" under the tab. This happens because TypeScript needs time to resolve the code in my cases. But rarely encountered.
For the minimal reproduction, I think which is the simplest code that consistently triggers the bug.

I can somewhat confirm this since, my project is right now considerably minimal

Could you please share your code with me so I can investigate further the issue? with github, sandbox or any other ways.

@dtrongphuc
Copy link

@Donovan-Ye This issue occasionally appears around 30 minutes to 1 hour after I start working in VSCode. In my case, I'm working on a file with several components, and Cmd + Click works well initially. However, when I open another file that also has components, Cmd + Click gets stuck, and CPU usage increases to 80% - 90%.

Just disable the extension, and I haven't seen this issue again.

image image

@Donovan-Ye
Copy link
Contributor

image

Yes, this issue occurs occasionally. Version 0.2.0 might trigger it when working with another plugin. I will investigate further. Thank you!

@s3xysteak
Copy link

s3xysteak commented Nov 4, 2024

It seems to be a race condition issue. Assume we trigger provideDefinition twice almost in the same time - let's call it A and B:

First, set triggerDoc = A.doc and triggerPos = A.pos. Almost simultaneously, this state also occurs for B. As a result, it enters a cycle: when the state is A, the recursive state becomes B, which means both of them can't be caught by // prevent infinite loop and reduce unnecessary calls statement.

To repro it, we can add a delay manually(This also shows that the problem usually occurs on machines with worse performance):

function sleep(ms: number) {
  return new Promise(res => setTimeout(res, ms))
}

Add the code here: https://github.com/antfu/vscode-goto-alias/blob/main/src/index.ts#L48

triggerPos = position

console.log('hi') // for test
await sleep(500)

Use any code like:

const one = 1
const two = 2

Hold down ctrl and move the mouse back and forth between the two of them. On my computer this can stably reproduce the issue.

To fix it, I think use WeakSet to store current instance may be a good solution.

@dickofn
Copy link
Author

dickofn commented Nov 4, 2024

After trying several times, I discovered that when I reload VSCode and use command+click to go to the definition, it sometimes shows "loading progress" under the tab. This happens because TypeScript needs time to resolve the code in my cases. But rarely encountered.
For the minimal reproduction, I think which is the simplest code that consistently triggers the bug.

I can somewhat confirm this since, my project is right now considerably minimal

Could you please share your code with me so I can investigate further the issue? with github, sandbox or any other ways.

really sorry this project is internal only, I also can confirm other people reply about high CPU usage after the infinite loading start

@Donovan-Ye
Copy link
Contributor

It seems to be a race condition issue. Assume we trigger provideDefinition twice almost in the same time - let's call it A and B:

First, set triggerDoc = A.doc and triggerPos = A.pos. Almost simultaneously, this state also occurs for B. As a result, it enters a cycle: when the state is A, the recursive state becomes B, which means both of them can't be caught by // prevent infinite loop and reduce unnecessary calls statement.

To repro it, we can add a delay manually(This also shows that the problem usually occurs on machines with worse performance):

function sleep(ms: number) {
  return new Promise(res => setTimeout(res, ms))
}

Add the code here: https://github.com/antfu/vscode-goto-alias/blob/main/src/index.ts#L48

triggerPos = position

console.log('hi') // for test
await sleep(500)

Use any code like:

const one = 1
const two = 2

Hold down ctrl and move the mouse back and forth between the two of them. On my computer this can stably reproduce the issue.

To fix it, I think use WeakSet to store current instance may be a good solution.

Excellent! I will give it a try and make the necessary corrections as soon as possible.

@Donovan-Ye
Copy link
Contributor

@s3xysteak Thank you for your inspiration! It was indeed caused by a race condition.

Initially, I attempted to add a WeakSet. However, if it is not cleaned properly, subsequent attempts to control+click on the definition will fail to navigate to the intended location.

And I found even if the provideDefinition function of goto-alias returns null, VSCode will still execute other provideDefinition functions by default. Therefore, I believe it just need to to implement a locking mechanism while one goto-alias' provideDefinition function is running and remove the lock once it has finished.

@Donovan-Ye
Copy link
Contributor

Please upgrade to version 0.2.1. If the issue still happens, please respond here~

@dickofn
Copy link
Author

dickofn commented Nov 4, 2024

Please upgrade to version 0.2.1. If the issue still happens, please respond here~

Now works better, there is no stuck at all but with a new problem on my side.

Sometimes it perfectly goes to the definition, but sometimes it goes to .nuxt\components.d.ts instead

It's unimportant, but I just put it here for your information.

@Donovan-Ye
Copy link
Contributor

Please upgrade to version 0.2.1. If the issue still happens, please respond here~

Now works better, there is no stuck at all but with a new problem on my side.

Sometimes it perfectly goes to the definition, but sometimes it goes to .nuxt\components.d.ts instead

It's unimportant, but I just put it here for your information.

ok~ I will fix it later.

@dickofn
Copy link
Author

dickofn commented Nov 4, 2024

ok~ I will fix it later.

Thanks a lot @Donovan-Ye it really improves my coding experience with Nuxt, cheers 🥂

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants