microsoft / microsoft/monaco-editor
[Bug] Explicitly triggered inline completions with promise occasionally raising Uncaught (in promise) Canceled: Canceled
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?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
Monaco Editor Playground Code
monaco.languages.registerInlineCompletionsProvider("lua", {
freeInlineCompletions(completions) { console.log('free', completions) },
provideInlineCompletions: async function (model, position, context, token) {
if( context.triggerKind == monaco.languages.InlineCompletionTriggerKind.Explicit) {
// wait 100ms to return value
var promise = new Promise((resolve) => {
setTimeout(()=> {
resolve("hey");
}, 100);
})
var value = await promise;
return {
items: [{
insertText: value,
text: value,
}],
enableForwardStability: true,
}
}
return { items: [] }
},
});
var editor = monaco.editor.create(document.getElementById("container"), {
value: 'function foo() print("hey") end',
language: "lua",
});
editor.addAction({
id: 'test',
label: 'test',
keybindings: [monaco.KeyMod.CtrlCmd|monaco.KeyMod.Shift|monaco.KeyCode.KeyA],
run: () => {
editor.trigger('source - use any string you like', 'editor.action.inlineSuggest.trigger', {});
},
});
Reproduction Steps
Hit Enter to create new line
Press Ctrl+Shift+A to explicitly trigger an inline completion.
It's not 100% reproducible - sometimes the error is not printed.
Actual (Problematic) Behavior
Error is printed in console.
Expected Behavior
No error should be displayed
Additional Context
I thought this might be a regression of this bug ( https://github.com/microsoft/monaco-editor/issues/2771 ) but that one I can't reproduce in the playground anymore.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Monaco Editor Playground link and the inline completions provider's provideInlineCompletions callback, especially the editor.action.inlineSuggest.trigger path and its delayed promise. Reproduce the Enter and Ctrl+Shift+A sequence, then trace cancellation handling for the pending promise. Done means the supplied example no longer prints an uncaught Canceled error in the console.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100