microsoft / microsoft/monaco-editor

[Bug] Uncaught context cancellation error when using an inline provider

Open
#4,767 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

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

https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.0#XQAAAAIHAgAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw0ZaM6AEiAKctgAboa7AI8gn8BvNILczn-ntn_Op7J0iRiSJoSu8H-xEmbUTTxoDxiCFJnJB__-tl61bXWsYajlaxKSnlOpvUCnmPrnnXffnwnYRri2goI2pZOIVa4-lvv96se_l5fCIXld3qjIeDIH6yOKHZQUXq_vxTRha6CVReTK0AhPMNml7WO9U2AXhR63ewx2muJQD4NWSmjDnhnp5otSyhXXruKxFjIj-nIqQTLo6Jmckx1aYBBXQoJkxppW2fxcG7vo9zmziyDTTg9VjtbE9forAZvjbWo8JWTDL9TcLgdf1R3aQEEkgCfRdjTq6UaNauBbXSOtO3kphjmgXj23Fbkzw0l665avcf_5kNwAA

Monaco Editor Playground Code
const value = "";
const editor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "plaintext",
});

monaco.languages.registerInlineCompletionsProvider("plaintext", {
	provideInlineCompletions(model, position, context, token) {
		return {
			items: [
				{
					insertText: "abc"
				},
				{
					insertText: {
						snippet: "var variable = \"${1:value}\""
					}
				}
			]
		};
	},

	freeInlineCompletions() {

	}
});
Reproduction Steps

Browser: Google Chrome Version 131.0.6778.85 (Official Build) (arm64)
Operating System: macOS Sonoma 14.4

  1. Type v in the preview editor.
  2. The inline completion should appear.
  3. Hit the Tab key.
  4. An error will now appear in the browser console.
editor.main.js:52017 Uncaught (in promise) Canceled: Canceled
    at UniqueContainer.value (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:52017:24)
    at Emitter._deliver (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:12271:26)
    at Emitter.fire (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:12300:22)
    at MutableToken.cancel (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:12686:35)
    at CancellationTokenSource.cancel (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:12733:29)
    at Object.dispose (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:12754:40)
    at dispose (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:5534:27)
    at DisposableStore.clear (https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:5617:17)
    at https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:22304:19
    at https://microsoft.github.io/monaco-editor/node_modules/monaco-editor/dev/vs/editor/editor.main.js:22297:17
Actual (Problematic) Behavior

Error appears in the browser console.

Expected Behavior

There should be nothing in the browser console.

Additional Context

No response

Contributor guide

Open the contributing guide

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.

Research direction

Start with the Monaco Editor Playground link and the registerInlineCompletionsProvider example, then trace cancellation when Tab accepts an inline completion. Done means reproducing the case and seeing no uncaught Canceled error in the browser console.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.