monaco-languageclient icon indicating copy to clipboard operation
monaco-languageclient copied to clipboard

onDidChangeConfiguration is not a function error in both `wrapper-react` and standard use.

Open brochington opened this issue 1 year ago • 37 comments

I'm receiving a very similar error to #686:

contextKeyService.js:82 Uncaught (in promise) TypeError: this._configurationService.onDidChangeConfiguration is not a function
    at new ConfigAwareContextValuesContainer (contextKeyService.js:82:1)
    at new ContextKeyService (contextKeyService.js:314:1)
    at InstantiationService._createInstance (instantiationService.js:120:1)
    at InstantiationService._createServiceInstance (instantiationService.js:224:1)
    at InstantiationService._createServiceInstanceWithOwner (instantiationService.js:212:1)
    at InstantiationService._createAndCacheServiceInstance (instantiationService.js:203:1)
    at InstantiationService._safeCreateAndCacheServiceInstance (instantiationService.js:161:1)
    at InstantiationService._getOrCreateServiceInstance (instantiationService.js:147:1)
    at Object.get (instantiationService.js:70:1)
    at lifecycle.js:38:1
ConfigAwareContextValuesContainer @ contextKeyService.js:82
ContextKeyService @ contextKeyService.js:314
_createInstance @ instantiationService.js:120
_createServiceInstance @ instantiationService.js:224
_createServiceInstanceWithOwner @ instantiationService.js:212
_createAndCacheServiceInstance @ instantiationService.js:203
_safeCreateAndCacheServiceInstance @ instantiationService.js:161
_getOrCreateServiceInstance @ instantiationService.js:147
get @ instantiationService.js:70
(anonymous) @ lifecycle.js:38
invokeFunction @ instantiationService.js:77
startup @ lifecycle.js:36
await in startup (async)
commitLayoutEffectOnFiber @ react-dom.development.js:23344
commitLayoutMountEffects_complete @ react-dom.development.js:24727
commitLayoutEffects_begin @ react-dom.development.js:24712
commitLayoutEffects @ react-dom.development.js:24651
commitRootImpl @ react-dom.development.js:26862
commitRoot @ react-dom.development.js:26721
finishConcurrentRender @ react-dom.development.js:26020
performConcurrentWorkOnRoot @ react-dom.development.js:25848
workLoop @ scheduler.development.js:266
flushWork @ scheduler.development.js:239
performWorkUntilDeadline @ scheduler.development.js:533

Same error occurs when using the wrapper-react as well as a more general approach:

const wrapper = new MonacoEditorLanguageClientWrapper();
await wrapper.init(getMonacoWrapperConfig());

Turning off HMR and liveReload results in the same error.

It's possible that this error is related to the bundler I'm using (rsbuild/rspack), but I've been able to get regular Monaco Editor working mostly out of the box.

I've create a test repro repo. Should just be able to npm install, npm run dev to see the error.

brochington avatar Jul 15 '24 22:07 brochington

@kaisalmen As always, the issue is multiple package version installed

[email protected] uses [email protected] and you're using @codingame/[email protected], instead of the 6.0.3

CGNonofr avatar Jul 16 '24 08:07 CGNonofr

@CGNonofr there must/should occur peerDependeny warnings. I have to check that independently

kaisalmen avatar Jul 16 '24 09:07 kaisalmen

image similar error image

wangyanci avatar Aug 01 '24 03:08 wangyanci

Did you check for multiple package version installed?

CGNonofr avatar Aug 01 '24 07:08 CGNonofr

i am also getting the same error, i have spent more than 5 hours trying to setup LSP into Monaco editor. Why there isn't any guide, I have tried looking the those examples, they are really confusing.

There are no guide or tutorial or blogs posted recently, all of them are outdated.

mxvsh avatar Sep 24 '24 12:09 mxvsh

i am using the same versions listed in the example repository - but still getting the error Screenshot 2024-09-24 at 17 58 10

contextKeyService.js:81 Uncaught (in promise) TypeError: this._configurationService.onDidChangeConfiguration is not a function

i only changed these packages because there version was updated

		"monaco-editor-wrapper": "next",
		"monaco-languageclient": "next",

mxvsh avatar Sep 24 '24 12:09 mxvsh

here is my package.json

"@codingame/monaco-vscode-keybindings-service-override": "8.0.4",
"@codingame/monaco-vscode-theme-defaults-default-extension": "8.0.4",
"@codingame/monaco-vscode-typescript-basics-default-extension": "8.0.4",
"@codingame/monaco-vscode-typescript-language-features-default-extension": "8.0.4",
"@monaco-editor/react": "^4.6.0",
"@typefox/monaco-editor-react": "next",
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~8.0.4",
"monaco-editor-wrapper": "next",
"monaco-languageclient": "next",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"vscode": "npm:@codingame/monaco-vscode-api@~8.0.4"

mxvsh avatar Sep 24 '24 12:09 mxvsh

i am also getting the same error, i have spent more than 5 hours trying to setup LSP into Monaco editor. Why there isn't any guide, I have tried looking the those examples, they are really confusing.

There are no guide or tutorial or blogs posted recently, all of them are outdated.

Feel free to make one as soon as you manage to make it work ;)

What is the result of npm list vscode?

CGNonofr avatar Sep 24 '24 13:09 CGNonofr

i am also getting the same error, i have spent more than 5 hours trying to setup LSP into Monaco editor. Why there isn't any guide, I have tried looking the those examples, they are really confusing. There are no guide or tutorial or blogs posted recently, all of them are outdated.

Feel free to make one as soon as you manage to make it work ;)

What is the result of npm list vscode?

sure, i will make a blog on it once i manage to set it up!! 😃

here is the log file btw of your command-

vscode.log

mxvsh avatar Sep 24 '24 14:09 mxvsh

You have both vscode@npm:@codingame/[email protected] and vscode@npm:@codingame/[email protected], because of [email protected]

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

@CGNonofr so what do i do? 😄

mxvsh avatar Sep 24 '24 15:09 mxvsh

@CGNonofr if you have a working code/repository with you, could you please share it with me 😄

mxvsh avatar Sep 24 '24 15:09 mxvsh

There is a compatibility table

Also you probably shouldn't use the next version since there is a more recent stable version

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

okay, i am trying to make a new project add one by one from that table, and i will let you know

mxvsh avatar Sep 24 '24 15:09 mxvsh

@mxvsh basically do not mix different versions of the same dependency in one project. Have you successfully checked out this repo, build everything and used the examples? The README is quite detailed. Which information is missing / unclear. Enhancement PRs are appreciated.

kaisalmen avatar Sep 24 '24 15:09 kaisalmen

Screenshot 2024-09-24 at 21 09 48

from the table, i believe monaco-editor-react is @monaco-editor/react because monaco-editor-react on npm is outdated (last updated 6 years ago). But when I try to install @monaco-editor/react, I get this error.

This error happened while installing a direct dependency of /Users/monawwar/dev/poc/monaco-editor

The latest release of @monaco-editor/react is "4.6.0".
Other releases are:
  * beta: 4.5.0-beta.0

mxvsh avatar Sep 24 '24 15:09 mxvsh

You're confusing @monaco-editor/react with monaco-editor-react which are 2 different libraries

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

I think it's @typefox/monaco-editor-react you're looking for, and you've already installed it along with the other one

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

btw @kaisalmen why is one namespaced and not the other?

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

@CGNonofr monaco-editor-react was there ages ago and not developed by us. I namespaced @typefox/monaco-editor-react because of that.

kaisalmen avatar Sep 24 '24 15:09 kaisalmen

I should have done the same with monaco-editor-wrapper

kaisalmen avatar Sep 24 '24 15:09 kaisalmen

@CGNonofr i tried in a completely new project - but still getting that error.

i checked with the table, it all matches with one row.

here is the repository-

https://github.com/mxvsh/monaco-editor-poc

mxvsh avatar Sep 24 '24 15:09 mxvsh

here is the log btw npm list vscode

vscode.log

mxvsh avatar Sep 24 '24 15:09 mxvsh

A simple check to the pnpm-lock.yaml shows that you have both 8.0.4 and 9.0.3 versions of monaco-vscode-api

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

@CGNonofr but i just created a new project - how come it installed two different versions?

i am sorry - but can you tell me how to fix it 😢

mxvsh avatar Sep 24 '24 15:09 mxvsh

by installing a dependency A directly, and having another dependency B that requires the dependency A with another version

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

As the compatibility table states, [email protected] should not be used with v9 of monaco-vscode-api (and all other @codingame packages)

also, you don't need monaco-editor

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

when i run without installing monaco-editor package, i get this error

Screenshot 2024-09-24 at 21 26 13

mxvsh avatar Sep 24 '24 15:09 mxvsh

btw @kaisalmen, having monaco-editor in the compatibility table is quite confusing, it's only for informative purpose and we should probably say that it shouldn't be installed

CGNonofr avatar Sep 24 '24 15:09 CGNonofr

"dependencies": {
  "@codingame/monaco-vscode-keybindings-service-override": "^9.0.3",
  "@codingame/monaco-vscode-theme-defaults-default-extension": "^9.0.3",
  "@codingame/monaco-vscode-typescript-basics-default-extension": "^9.0.3",
  "@codingame/monaco-vscode-typescript-language-features-default-extension": "^9.0.3",
  "@typefox/monaco-editor-react": "^4.5.3",
  "monaco-editor-wrapper": "5.5.3",
  "react": "^18.3.1",
  "react-dom": "^18.3.1"
},

mxvsh avatar Sep 24 '24 15:09 mxvsh