[Bug] Error: [createInstance] CodeLensContribution depends on UNKNOWN service ICodeLensCache.

Open
#5,491 2 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@hediet is already working on this.

Since Sep 29, 2026.

Assessment

This issue has not been assessed yet.

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

I'm using 0.57.0 along with monaco-editor-webpack-plugin.

My monaco-editor-webpack-plugin config looks like this:

new MonacoWebpackPlugin({
	languages: ['json', 'html', 'javascript'],
	filename: getFileName('js', 'worker'),
	features: [
		'!caretOperations',
		'!codeAction',
		'!codelens',    // BUG RELATED
		'!colorPicker',
		'!dnd',
		'!gotoSymbol',
		'!linkedEditing',
		'!multicursor',
		'!referenceSearch',
		'!smartSelect',
		'!snippet',
		'!stickyScroll',
		'!toggleHighContrast',
		'!inlineCompletions',
		'!inlineProgress',
	]
})

I create Monaco editors with this config:

export const defaultEditorOptions = {
	minimap: { enabled: false },
	scrollBeyondLastLine: false,
	lineNumbers: 'off',
	renderLineHighlight: 'none',
	selectOnLineNumbers: true,
	automaticLayout: true,
	theme: 'defaultTheme',
	scrollbar: { alwaysConsumeMouseWheel: false },
	renderValidationDecorations: 'on',
	codeLens: false,      // BUG RELATED
};

When I instantiate an editor, it does render on my page but sometimes without styling the text. Furthermore, there are console errors like this. I was previously on 0.52.0 and didn't have this problem. I ran into it while testing the upgrade to 0.57.0.

errors.js:15 Uncaught Error: [createInstance] CodeLensContribution depends on UNKNOWN service ICodeLensCache.

Error: [createInstance] CodeLensContribution depends on UNKNOWN service ICodeLensCache.
    at InstantiationService._throwIfStrict (instantiationService.js:333:1)
    at InstantiationService._createInstance (instantiationService.js:114:1)
    at InstantiationService.createInstance (instantiationService.js:102:1)
    at CodeEditorContributions._instantiateById (codeEditorContributions.js:120:1)
    at CodeEditorContributions._instantiateSome (codeEditorContributions.js:98:1)
    at eval (codeEditorContributions.js:46:1)
    at InstantiationService._throwIfStrict (instantiationService.js:333:1)
    at InstantiationService._createInstance (instantiationService.js:114:1)
    at InstantiationService.createInstance (instantiationService.js:102:1)
    at CodeEditorContributions._instantiateById (codeEditorContributions.js:120:1)
    at CodeEditorContributions._instantiateSome (codeEditorContributions.js:98:1)
    at eval (codeEditorContributions.js:46:1)
    at eval (errors.js:15:1)

I would expect since I have codeLens disabled in webpack and codeLens disabled on the editor options, that nothing would try to instantiate codeLens! Debugging in my browser, I see "css.editor.codeLens" is the ID trying to create it, which also makes no sense since I never tell Monaco to use CSS:

Image
Monaco Editor Playground Code

Reproduction Steps

No response

Actual (Problematic) Behavior

No response

Expected Behavior

No response

Additional Context

No response

Dominant language
JavaScript
Stars
47k
Forks
4.2k
Avg merge
3d 13h
Merged PRs (30d)
13

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/monaco-editor

All issues in microsoft/monaco-editor

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.