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

Getting same multiple suggestions on force stop and reconnecting the language client with language servers. #387

Closed
anonymous9915 opened this issue Jun 21, 2022 · 34 comments

Comments

@anonymous9915
Copy link

If I close the websocket and stopped the language client, and then re-established the language client connection again with the same language, then the editor is showing multiple suggestion. This is happening with all the languages Java, Python, C++ and C.
Screenshot (114)

@CGNonofr
Copy link
Collaborator

Can you provide some code sample? I'm not able to reproduce

@anonymous9915
Copy link
Author

This is file line link
https://github.com/anonymous9915/Monaco-Editor-Test/blob/master/src/app/monaco-editor/monaco-editor.component.ts
where i integrated the monaco client and monaco editor.
You can open the repository on gitpod https://gitpod.io/#https://github.com/anonymous9915/Monaco-Editor-Test
to view the UI.
First selected language is CPP. Change it to Python and then again change to CPP. now cpp show multiple suggestions. same for python as well.
Everytime i changes the languages i stopped the client and close the websocket and dispose other listeners.
For development my backend sever is up only for certain time. When you open the Gitpod Url please ping so that i can check if the server is UP or not so you can view the issue live.

@CGNonofr
Copy link
Collaborator

The gitpod seems to already be down

@anonymous9915
Copy link
Author

started the server. Please check now

@anonymous9915
Copy link
Author

@CGNonofr
Copy link
Collaborator

Ok, the markers are not cleaned when the language client is removed.

Can you give a try with the v2.0 of this library?

@anonymous9915
Copy link
Author

I tried that as well, but in that case i json rpc messages was not sent to the server. I will check that again to deep dive that case.

Is there any public method available so that I can clear the markers.

@anonymous9915
Copy link
Author

Also Client got automatically closed after some minutes of inactivity. can we increase that timeout ?

@CGNonofr
Copy link
Collaborator

Is there any public method available so that I can clear the markers.

You're not supposed to have to do it by hands, I'm pretty confident the v2 fixes this

Also Client got automatically closed after some minutes of inactivity. can we increase that timeout ?

I don't think there is any timeout here

@anonymous9915
Copy link
Author

Ok, let me check with v2 version. will update here.

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jun 22, 2022

@kaisalmen a migration guide, or at least a BREAKING CHANGE entry in the CHANGELONG may be required

To use the v2, you need at least:

  • To remove the webpack vscode alias
  • To update the monaco services (if you customized it)

@anonymous9915
Copy link
Author

Getting these errors.
Module not found: Error: Can't resolve 'vscode' in '/workspace/Monaco-Editor-Test/node_modules/vscode-languageclient/lib/common'

After removing the vscode alias

@CGNonofr
Copy link
Collaborator

After the update to the v2.0.1?

@anonymous9915
Copy link
Author

yes

@CGNonofr
Copy link
Collaborator

vscode is now a dependency, you're supposed have a vscode folder in your node_modules

@anonymous9915
Copy link
Author

I have installed the vscode 1.1.37.

@CGNonofr
Copy link
Collaborator

You're not supposed to install vscode, vscode is installed as an alias to npm:@codingame/monaco-vscode-api@^1.68.4

@anonymous9915
Copy link
Author

anonymous9915 commented Jun 22, 2022

In that case it is not present.
You can check here https://anonymous99-monacoedito-h9zj18o7xdq.ws-us47.gitpod.io

@anonymous9915
Copy link
Author

What external dependencies do I need to install other than monaco language client ?
It would be a better if we have the migration guide.

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jun 22, 2022

What external dependencies do I need to install other than monaco language client ?

Nothing

I've removed your package-lock.json and your node_modules, then run npm install and everything seems fine now

@anonymous9915
Copy link
Author

Ok thanks.
But now auto complete seems to be stopped and I am not getting suggestions as I was getting earlier.

@CGNonofr
Copy link
Collaborator

For some reasons, the file are not open anymore, it's often related to a library being duplicated in the node_modules

@anonymous9915
Copy link
Author

didOpen call is not going to the server.

@CGNonofr
Copy link
Collaborator

Ok it seems ngx-monaco-editor is loading monaco-editor from the cdn which breaks everything

@anonymous9915
Copy link
Author

No it is not downloading it from cdn, but load it from the assests.

@CGNonofr
Copy link
Collaborator

I'm not sure what it means, but the result is probably the same

@anonymous9915
Copy link
Author

anonymous9915 commented Jun 22, 2022

ok, ngx-monaco-editor takes some time to load the monaco editor that's why i wait for monaco to be available in the window.
Once the monaco is available I created the editor and install the services which was working until 1.1.0.
Is from 2.0.1 client requires monaco to be available from starting ?
But before installing the services, why language client requires the monaco to be available.

@CGNonofr
Copy link
Collaborator

Starting from 2.0, the lib is importing monaco-editor directly

In the v1.0, it was expecting the monaco namespace to be provided

I think the issue is that it's loading the amd version (min/vs) while this lib is loading the esm version (esm/vs)

I'll investigate, give me some time

@anonymous9915
Copy link
Author

ok, got it. meanwhile I will try to install the esm version

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jun 22, 2022

Oh I managed to make it work (MonacoEditorLoaderService should not be used), but there is still the diagnostics issue

@anonymous9915
Copy link
Author

Just checked, suggestions are working, there are some issues in the UI (that I will look), but marker issue is still there.

@CGNonofr
Copy link
Collaborator

Ok, I found the issue.

The issue is that you dispose the model too soon. if you put the dispose in a small timeout, the issue disappears.

The bug is not fixable until microsoft/vscode#151237 is released in the next monaco editor version.

@anonymous9915
Copy link
Author

Ok, Autocomplete and markers are woking fine now. Thank you very much. setTimeout fix is working for v1.1.0 also.
But v2 is quite clear and simple, I will update to this version and will look into the UI issues.
I think we can close this issue.

@anonymous9915
Copy link
Author

Also can I close the Backend server and workspace that I shared, If you are not using that.

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

No branches or pull requests

2 participants