microsoft / microsoft/monaco-editor

[Bug] Explicitly triggered inline completions with promise occasionally raising Uncaught (in promise) Canceled: Canceled

Open
#4,554 0 comments 5 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.49.0#XQAAAAJwBAAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw6pXnyT9RSPWJrMzrzzSucLOyj4KniHiZODaDJyQLYDbXulsGhSWLNbXK-oOQlkShiZcobhJrftFlfAcmwhyFRKBn_IO53rBhW5f-Eh_hsUjVO4OrLejxx8ojNRoZEjo3erZ4f2X14YvDlCUmie2LxJOy9QMSRye7Z34Ri3qy6LkwYpWaiKVIUcz-Bk_G-YbGbUHRL8O503GOU1qNuTD7lAQrHROmtVwrpiesQOqQqCptpdAEFJwi6tRpbHdIUk-nNDjsKLWxv263Q6D5Pkwyvqk8IP3YdnQewVbKXEI72QSHD15QaK-O4xXVcKw0anlc7_HEcDbFqf7L5F15QWrxNCZsHgsKVsAvdNWmXARmlgOvYpI0F_tAymClfkKzG4JtGMMPEekqwuBUT3j948_Vy50Cb-kFWD2vvXLLUl70N9_7kyCzWNOXbFCjD5xk3RgHX3fFZE6OPger-Pc3c2Nnpi1QBwn91gh6bFOTuLlHWs1UhbaezLeOhF_OELCRl8E05M1bBXydM2hdQ-494iw7EFrfYlVJ56sK4RR6iUBqU8j6jp_0sCb5GKM1MQSHCNQ4h-F2TFYuDPWcwhmV_5zMw30JB2-XwPpjRQ2N0pNUA01ilrINommS8lWTk4x3hUpFgYdOKigbpI7Gob1rw_bL5FH8vDwveeQOMKUmGrJZEcWQznhImBJbPk_6daSVtApp4iiC8YOuSXo0IE1SDmVts3A1ptZLkfHB4He-TgfJ_1-dGgA

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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.