monaco-vscode-api: Uncaught Error: Cannot have two contributions with the same id editor.contrib.referencesController

I am trying to update my monaco editor to 1.41.0, with the recommended monaco-langaugeclient 6.4.6 and monaco-vscode-api 1.81.7. I used to have some code that worked using monaco-editor 0.36 and now have to update the entire service setup.

I have followed to demo (I think), calling the initialize function like this:

    await initializeMonacoServices({
        ...getConfigurationServiceOverride(monaco.Uri.file("/tmp")),
        ...getEditorServiceOverride(openEditor),
        ...getLanguagesServiceOverride(),
        ...getModelServiceOverride(),
        ...getSnippetServiceOverride(),
        ...getStorageServiceOverride(),
    });

I think this is probably more than what I even need šŸ˜‰ But whatever I do (even when calling the initialize method without any services) I do run into this error:

Uncaught Error: Cannot have two contributions with the same id editor.contrib.referencesController

initialize@http://localhost:3001/node_modules/.vite/deps/chunk-BRCXZLFB.js?v=7b9dc333:87116:27
CodeEditorWidget2@http://localhost:3001/node_modules/.vite/deps/chunk-BRCXZLFB.js?v=7b9dc333:87419:25
StandaloneCodeEditor2@http://localhost:3001/node_modules/.vite/deps/chunk-3DMOLLPZ.js?v=7b9dc333:109:5
StandaloneEditor2@http://localhost:3001/node_modules/.vite/deps/chunk-3DMOLLPZ.js?v=7b9dc333:213:5
@http://localhost:3001/node_modules/.vite/deps/vscode_monaco.js?v=7b9dc333:497:7
ConfiguredStandaloneEditor2@http://localhost:3001/node_modules/.vite/deps/vscode_monaco.js?v=7b9dc333:3688:5
_createInstance@http://localhost:3001/node_modules/.vite/deps/chunk-BRCXZLFB.js?v=7b9dc333:57950:20
createInstance@http://localhost:3001/node_modules/.vite/deps/chunk-BRCXZLFB.js?v=7b9dc333:57925:21
createConfiguredEditor@http://localhost:3001/node_modules/.vite/deps/vscode_monaco.js?v=7b9dc333:3784:52
setup_editor@http://localhost:3001/src/editor_widget.ts:433:42
EditorPaneWidget@http://localhost:3001/src/editor_widget.ts:155:25
EditorWidget@http://localhost:3001/src/editor_widget.ts:587:20
setup@http://localhost:3001/src/index.ts:391:18
main/<@http://localhost:3001/src/index.ts:483:10
promise callback*main@http://localhost:3001/src/index.ts:482:91
EventHandlerNonNull*@http://localhost:3001/src/index.ts:493:1
    unexpectedErrorHandler errors.js:15
    setTimeout handler*node_modules/monaco-editor/esm/vs/base/common/errors.js/ErrorHandler/this.unexpectedErrorHandler errors.js:10
    onUnexpectedError errors.js:42
    onUnexpectedError errors.js:72
    initialize codeEditorContributions.js:36
    CodeEditorWidget2 codeEditorWidget.js:213
    StandaloneCodeEditor2 standaloneCodeEditor.js:67
    StandaloneEditor2 standaloneCodeEditor.js:183
    <anonymous> injection.js:11
    ConfiguredStandaloneEditor2 monaco.js:79
    _createInstance instantiationService.js:97
    createInstance instantiationService.js:68
    createConfiguredEditor monaco.js:175
    setup_editor editor_widget.ts:562
    EditorPaneWidget editor_widget.ts:257
    EditorWidget editor_widget.ts:770
    setup index.ts:468
    main index.ts:591
    promise callback*main index.ts:590
    EventHandlerNonNull* index.ts:605
errors.js:15:26

I am pretty sure I am just using this wrong, but I would still appreciate any ideas on how I can debug this.

About this issue

  • Original URL
  • State: closed
  • Created 10 months ago
  • Comments: 21 (7 by maintainers)

Most upvoted comments

@hunger that’s good news!

I removed some import * as monaco from ā€œmonaco-editor/esm/vs/editor/editor.apiā€; and now the first message is gone!

@CGNonofr how can this be if there are no rivaling monaco-editor versions?

Yeah that’s doesn’t make sense to me at all. I still vote for a cache issue

Next step: Move my hand-crafted model management over to the new-thingā„¢.

I had a few different imports to files in monaco-editor in my codebase and have replaced all of them with a simple ā€œmonaco-editorā€ now. I guess one of them is not intended for inclusion by users anymore.

The current code using monaco-editor 0.36.1 is here by the way: https://github.com/slint-ui/slint/tree/master/tools/slintpad

My quick-and-probably-too-dirty attempt to upgrade is in my private fork: https://github.com/hunger/slint/tree/slintpad_monaco_update/tools/slintpad