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

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

Open
brochington opened this issue Jul 15, 2024 · 41 comments

Comments

@brochington
Copy link

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.

@CGNonofr
Copy link
Collaborator

CGNonofr commented Jul 16, 2024

@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

@kaisalmen
Copy link
Collaborator

kaisalmen commented Jul 16, 2024

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

@wangyanci
Copy link

image
similar error
image

@CGNonofr
Copy link
Collaborator

CGNonofr commented Aug 1, 2024

Did you check for multiple package version installed?

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

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
Copy link

mxvsh commented Sep 24, 2024

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
Copy link

mxvsh commented Sep 24, 2024

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"

@CGNonofr
Copy link
Collaborator

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?

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

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

@CGNonofr
Copy link
Collaborator

CGNonofr commented Sep 24, 2024

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

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

@CGNonofr so what do i do? 😄

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

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

@CGNonofr
Copy link
Collaborator

There is a compatibility table

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

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

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

@kaisalmen
Copy link
Collaborator

kaisalmen commented Sep 24, 2024

@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.

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

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

@CGNonofr
Copy link
Collaborator

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

@CGNonofr
Copy link
Collaborator

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

@CGNonofr
Copy link
Collaborator

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

@kaisalmen
Copy link
Collaborator

kaisalmen commented Sep 24, 2024

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

@kaisalmen
Copy link
Collaborator

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

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

@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
Copy link

mxvsh commented Sep 24, 2024

here is the log btw npm list vscode

vscode.log

@CGNonofr
Copy link
Collaborator

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

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

@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 😢

@CGNonofr
Copy link
Collaborator

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

@CGNonofr
Copy link
Collaborator

CGNonofr commented Sep 24, 2024

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

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

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

Screenshot 2024-09-24 at 21 26 13

@CGNonofr
Copy link
Collaborator

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

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

"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"
},

@CGNonofr
Copy link
Collaborator

monaco editor should be installed as an alias to @codingame/monaco-editor-api instead

Which should be the case because it's declared in the dependencies of monaco-editor-wrapper

@kaisalmen
Copy link
Collaborator

@mxvsh use 8.0.4 instead of 9.0.3 for all monaco-vscode dependencies. 9.x is not yet supported.

"@codingame/monaco-vscode-keybindings-service-override": "^9.0.3",

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

Thanks! That error is gone with the following dependency -

"dependencies": {
  "@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",
  "@typefox/monaco-editor-react": "^4.5.3",
  "monaco-editor": "npm:@codingame/[email protected]",
  "monaco-editor-wrapper": "5.5.3",
  "react": "^18.3.1",
  "react-dom": "^18.3.1"
},

but I got another error - 😭

Screenshot 2024-09-24 at 21 33 21
Uncaught (in promise) Error: Unable to figure out browser width and height
    at getClientArea (dom.js:315:13)
    at LayoutService.layout (layout.js:352:40)
    at new LayoutService (layout.js:63:14)
    at _InstantiationService._createInstance (instantiationService.js:120:24)
    at instantiationService.js:238:38

@kaisalmen
Copy link
Collaborator

@mxvsh please share a repo with your example than we can have a look.

@mxvsh
Copy link

mxvsh commented Sep 24, 2024

@kaisalmen i shared before, i will share it again 😃

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

@kaisalmen
Copy link
Collaborator

Sorry, I missed that.

@caner-cetin
Copy link

caner-cetin commented Oct 13, 2024

There is a compatibility table

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

holy fucking shit both projects needs an AIO package desperately. I have wrote example Python code 1:1, WS connection is alive, all is fine on server, and I get the same error

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

problem is package json is taller than the berlin wall right now, I know there is a version that works (mxvsh s versions doesnt work for me), but looking at compat table and reinstalling all of these is really, really unintiutievevj (forgot the word).

Thanks for this awesome project by the way. It is perfect for everything, and it is perfect when used like a level between monaco, like instead of connecting the lower level Monaco to the LSP and sending all commands by myself, I can just use monaco languageserver library. but I want the whole package like in Python example, and, holy hell, this is worrying me.

edit: mxvsh s versions does not work with either bun, npm, pnpm, everything I throw at this thing refuses to work with same error

#686 (comment)

last edit because it is 4 am in the morning, here is my latest dependency tree. I feel like no need for MRP, you can reproduce it in same way with the mxvsh's MRP.
resim
i dont know what is wrong, but I have spent 6 hours on this error. tried almsot all compatible versions.

@kaisalmen
Copy link
Collaborator

@mxvsh and @caner-cetin I was busy with other things and then away last week. I will provide feedback this week.

@Harry-Drew-CyanBytes
Copy link

I'm getting the same issue.
image
I'm specifically getting the issue when trying to integrate with React. When I download the example project it works fine: https://github.com/TypeFox/monaco-languageclient but when i try to produce a minimal recreation of just the react part (with a language server) i get the error. Any news or updates on this issue and does anyone have a barebones example of a react implementation (not in a massive mono repo) 😄

@caner-cetin
Copy link

I cant provide help or support, moved onto Ace Editor instead of Monaco and I cant remember what I did. best I can say is check versions of packages, at least package.json and vite config file in main example folder is helpful.

@kaisalmen
Copy link
Collaborator

Package mismatch seems to be a repeating problem. I have opened #789 to track this and hopefully find a more reliable solution for it.

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

7 participants