monaco-editor icon indicating copy to clipboard operation
monaco-editor copied to clipboard

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

Open qsc-jhndnn opened this issue 8 months ago • 0 comments

Reproducible in vscode.dev or in VS Code Desktop?

  • [X] 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.

qsc-jhndnn avatar Jun 10 '24 16:06 qsc-jhndnn