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

extension moduel getLocalExtHostExtensionService blocked #541

Closed
coyzeng opened this issue Sep 21, 2023 · 29 comments
Closed

extension moduel getLocalExtHostExtensionService blocked #541

coyzeng opened this issue Sep 21, 2023 · 29 comments

Comments

@coyzeng
Copy link

coyzeng commented Sep 21, 2023

No description provided.

@kaisalmen
Copy link
Collaborator

@coyzeng Please take your time to describe your problem properly.

@OliverwengFiltered
Copy link

OliverwengFiltered commented Oct 5, 2023

I'm having the same issue after upgrading the monaco-languageclient to v6.5.1. (it builds/bundles successfully though)

did some debugging with break points on the front end. It looks like the getLocalExtHostExtensionService call promise in vscode/extensions.js never successfully resolve so the code doesn't hit line 39. (this call is triggered on initServices function under root monaco-languageclient lib, and because of this, the initServices promise never gets resolved.)

any insights? @kaisalmen

Screenshot 2023-10-05 at 10 25 20 AM

@kaisalmen kaisalmen reopened this Oct 5, 2023
@kaisalmen
Copy link
Collaborator

@CGNonofr do you have an idea?
@OliverwengFiltered can you reproduce this with our local webpack verification example?

@CGNonofr
Copy link
Collaborator

CGNonofr commented Oct 5, 2023

Was initializeExtensions called?

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered
Copy link

was doing some debugging, the code I was showing is inside the initializeExtensions call.

Screenshot 2023-10-05 at 2 43 35 PM

the above initialize function is this function as @kaisalmen pointed out, it's the bundled version.

and then I stepped into it, got the below image, and it stuck at the highlighted line and never got to the next line.

Screenshot 2023-10-05 at 2 44 03 PM

@samirzubi-db
Copy link

I am having the same issue as above where getLocalExtHostExtensionService promise does not resolve or reject.

@kaisalmen
Copy link
Collaborator

@OliverwengFiltered and @samirzubi-db are you using @codingame/monaco-vscode-theme-defaults-default-extension? Please try to await the whenReady before initializing your own extension, like here:
https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/src/python/client/main.ts#L90

@CGNonofr I have the suspicion it is related to this:
#544 (comment)

@samirzubi-db
Copy link

@kaisalmen thanks for the quick response I am not using @codingame/monaco-vscode-theme-defaults-default-extension. I am only calling initialize from vscode/services and then the initialize from vscode/extensions. I am not using any service overrides since I need only the default ones.

@kaisalmen
Copy link
Collaborator

kaisalmen commented Oct 6, 2023

@samirzubi-db or @OliverwengFiltered can you publish a reproducible example / repo somewhere? I can't reproduce what you see. I assume you cannot reproduce this with the examples from this repo or can you?

@coyzeng
Copy link
Author

coyzeng commented Oct 10, 2023

@samirzubi-db or @OliverwengFiltered can you publish a reproducible example / repo somewhere? I can't reproduce what you see. I assume you cannot reproduce this with the examples from this repo or can you?

https://github.com/coyzeng/monaco-example.git

image

@coyzeng
Copy link
Author

coyzeng commented Oct 10, 2023

image

@kaisalmen
Copy link
Collaborator

kaisalmen commented Oct 10, 2023

@coyzeng @OliverwengFiltered @CGNonofr thank you, whatever react does provokes the issue. I don't know why, yet.

When I move the init code to your main and comment the react usage the init works as expected:

const initMlc = async () => {
    await initServices({
        debugLogging: true
    });
};
console.log(0)
initMlc();
console.log(1)

// const root = ReactDOM.createRoot(document.getElementById('root')!);
// root.render(<SQLEditor/>);

image

Can it be that using useEffect provokes the problem?

@CGNonofr
Copy link
Collaborator

Wasn't it called too late? (after the editor creation/default services instantiation)

@kaisalmen
Copy link
Collaborator

Wasn't it called too late? (after the editor creation/default services instantiation)

It works until, I put the render function back in

@kaisalmen
Copy link
Collaborator

Is it Monday again?! I don't see a fundamental difference in our react example.

@kaisalmen
Copy link
Collaborator

The actual problem is not react, but defining monaco.editor.defineTheme directly in an import file (@github). If wrap that in an exported function and call it at a proper place. Everything works.

@kaisalmen kaisalmen reopened this Oct 10, 2023
@kaisalmen
Copy link
Collaborator

Sorry, closed this to quickly. @OliverwengFiltered should verify/comment if it is the same issue.

@samirzubi-db
Copy link

I had the same issue with the theme being declared directly. Thank you for looking into this @kaisalmen and @coyzeng for the repro!

@CGNonofr
Copy link
Collaborator

I'll add a check in the monaco-vscode-api service initialization to make sure the services aren't already initialized to prevent such confusing issues

@OliverwengFiltered
Copy link

OliverwengFiltered commented Oct 10, 2023

well, that did not solve my issue on my end. I will put together a sample project to reproduce in a few hours.

@kaisalmen
Copy link
Collaborator

well, that did not solve my issue on my end. I will put together a sample project to reproduce in a few hours.

Thank you.

@OliverwengFiltered
Copy link

Hi @kaisalmen and @CGNonofr

I have uploaded a public repo to reproduce the issue: https://github.com/OliverwengFiltered/monaco-test

simply follow the below steps to reproduce.

  1. clone the repo.
  2. npm install.
  3. npx webpack build
  4. npm start.
  5. visit localhost:3000
  6. the editor should load.
  7. now go to monacoInit.js and uncomment those lines.
  8. now start server again, you will see a blank state.

curious why calling Editor.getModels() will prevent the editor from being rendered with latest version. (same code is not painting blank state with monaco-languageclient v6.4.6)

@CGNonofr
Copy link
Collaborator

monaco.editor.getModels() initializes the services as well

@OliverwengFiltered
Copy link

@CGNonofr ok, so which api method should I use to check if it has been initialized or not ?

@OliverwengFiltered
Copy link

so in this case, @CGNonofr
if I have to do dispose() before editor's creation. any recommendations?
it seems currently, the Editor.getModels() and LanguageClientLib.initServices() are both initialize monaco services, and they can't co-exists in the new 6.5.2 version. And the check wasVscodeApiInitialized() returns false even if Editor.getModels() are called before hand.

Screenshot 2023-10-11 at 12 37 05 PM

@CGNonofr
Copy link
Collaborator

I think wasVscodeApiInitialized only returns true if it was initialized using the initServices method

You just need to wait for the service to be initialized before calling getModels

@OliverwengFiltered
Copy link

OliverwengFiltered commented Oct 11, 2023

that makes sense, @CGNonofr .

and I can confirm that calling LanguageClientLib.initServes() function before the .getModels function works.

Thanks, we can close this ticket now.

Thanks all.

@kaisalmen
Copy link
Collaborator

Wonderful. 🎉

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

5 participants