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

Missing initialize from vscode/extensions #283

Closed
char0n opened this issue Dec 6, 2023 · 8 comments · Fixed by #285
Closed

Missing initialize from vscode/extensions #283

char0n opened this issue Dec 6, 2023 · 8 comments · Fixed by #285

Comments

@char0n
Copy link

char0n commented Dec 6, 2023

Hi @CGNonofr,

It seems that following import now longer works:

import { initialize } from 'vscode/extensions'

initialize is no longer part of that file. Affected version is @codingame/monaco-vscode-api@=1.83.15.

@char0n
Copy link
Author

char0n commented Dec 6, 2023

Looking at a295d70 it seems it's been removed.

@char0n
Copy link
Author

char0n commented Dec 6, 2023

This documentation https://github.com/CodinGame/monaco-vscode-api#vscode-api-usage doesn't seem to be aligned with the actual code.

@char0n
Copy link
Author

char0n commented Dec 6, 2023

I figured I need to use:

import 'vscode/localExtensionHost';`

But it seems, that things will starts working only after I perform some action (like opening a command palette):

initialization.mp4

@char0n
Copy link
Author

char0n commented Dec 6, 2023

I did dig deeper and the issue is with monaco service initialization. The simplest code to reproduce:

import {  initialize as initializeMonacoServices } from 'vscode/services';
import 'vscode/localExtensionHost';

console.dir('initializing');
await initializeMonacoServices({});
console.dir('initialized');

initialized is never printed and the promise returned from initializeMonacoServices never resolves. Any idea what would be the problem?


Following seems to work; I'm performing some random service action which allows initialization to fall through (resolve).

import {  initialize as initializeMonacoServices,   StandaloneServices, IQuickInputService, } from 'vscode/services';
import 'vscode/localExtensionHost';

console.dir('initializing');
setTimeout(() => {
  StandaloneServices.get(IQuickInputService).quickAccess.show('>', {
    itemActivation: 0,
  });
}, 0);
await initializeMonacoServices({});
console.dir('initialized');

@CGNonofr
Copy link
Contributor

CGNonofr commented Dec 6, 2023

Working on way to improve the changelog

This documentation https://github.com/CodinGame/monaco-vscode-api#vscode-api-usage doesn't seem to be aligned with the actual code.

Right, will fix

initialized is never printed and the promise returned from initializeMonacoServices never resolves. Any idea what would be the problem?

No idea, I'm interested if you find the cause of it

@char0n
Copy link
Author

char0n commented Dec 6, 2023

No idea, I'm interested if you find the cause of it

I fails in vscode/lifecycle.js in

async function startup(instantiationService) {

specifically in:

    await instantiationService.invokeFunction(async (accessor) => {
        await Promise.all(( serviceInitializePostParticipants.map(participant => participant(accessor))));
    });

This will never resolve. If I remove this code, everything works as expected.

The serviceInitializePostParticipants list contains following single item:

image

@CGNonofr
Copy link
Contributor

CGNonofr commented Dec 6, 2023

It'll be fixed soon in #285

in the meantime, you can add this workaround:

import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions'
import { registerServiceInitializeParticipant } from 'vscode/lifecycle'

registerServiceInitializeParticipant(accessor => accessor.get(IExtensionService))

@char0n
Copy link
Author

char0n commented Dec 6, 2023

import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions'
import { registerServiceInitializeParticipant } from 'vscode/lifecycle'

registerServiceInitializeParticipant(accessor => accessor.get(IExtensionService))

I can confirm, the workaround works. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants