question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

onMouseLeave throws uncaught canceled

See original GitHub issue

I’m seeing uncaught errors when moving the cursor between the two halves of createDiffEditor.

Steps to Reproduce:

  1. Open up this HTML snippet, with dev tools running.
<!DOCTYPE html>
<html>
  <body>
    <div style="height: 50vh"></div>
    <script>
      window.require = {
        paths: {
          vs:
            "https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.23.0/min/vs/",
        },
      };
    </script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.23.0/min/vs/loader.min.js"></script>
    <script>
      require(["vs/editor/editor.main"], () => {
        const elem = document.querySelector("div");
        const editor = monaco.editor.createDiffEditor(elem);
        const original = monaco.editor.createModel("foo");
        const modified = monaco.editor.createModel("bar");
        editor.setModel({ original, modified });
      });
    </script>
  </body>
</html>
  1. Click anywhere on Monaco editor.
  2. Move the mouse between the two editor halves.
  3. You should see uncaught errors in the console log.

Error Output:

Uncaught (in promise) Canceled: Canceled
    at Object.d [as canceled] (/monaco/min/vs/editor/editor.main.js:8:711)
    at g.cancel (/monaco/min/vs/editor/editor.main.js:51:15831)
    at Function.onMouseLeave (/monaco/min/vs/editor/editor.main.js:103:10222)
    at /monaco/min/vs/editor/editor.main.js:103:5373
    at p.fire (/monaco/min/vs/editor/editor.main.js:51:1836)
    at HTMLDivElement.g (/monaco/min/vs/editor/editor.main.js:51:6378)

Notes

  • Reproduced in 0.22.x and 0.23.0.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
alexdimacommented, Mar 22, 2021

Shame this can’t be addressed.

🤷‍♂️ . This was fixed in https://github.com/microsoft/vscode/commit/49cad9a1c0d9ef01d66eef60b261c7ebcffcef23 , so it was addressed. I then went beyond fixing and offered you a temporary workaround you can use until we ship a new editor version.

2reactions
alexdimacommented, Mar 11, 2021

Found it. You could do the following in your app:

window.addEventListener('unhandledrejection', function(event) {
	if (event.reason && event.reason.name === 'Canceled') {
		// monaco editor promise cancelation
		event.preventDefault();
	}
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript cancel "mouseleave" event on "click" - Stack Overflow
I'm not able to cancel the "mouseleave" event. That element should only disappear when I click on "X" - but thats no problem....
Read more >
Uncaught Action failed: [Cannot read properties of undefined ...
Hi All, When i enter any word in the lookup in the component i ma getting this error: Uncaught Action failed: ...
Read more >
HTMLUncaughtScriptExceptionEvent - ActionScript 3.0 Language ...
An HTMLLoader object dispatches an HTMLUncaughtScriptExceptionEvent object whenever a JavaScript exception is thrown and not handled with a catch statement.
Read more >
Safari Technology Preview Release Notes - Apple Developer
toMatrix() to throw an exception if its length is not compatible with a px unit ... Updated Web Inspector to show the uncaught...
Read more >
Event loops - HTML Spec
JSON module scripts represent a parsed JSON document. As CSS stylesheets and JSON documents do not import dependent modules, and do not throw...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found