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

Crash on error due to missing telemetry

Open WitoDelnat opened this issue 3 years ago • 2 comments

Hello Remco, thank you for your continuous efforts on monaco-yaml!

Recently I've started doing something incorrectly as the Yaml language service throws an error. I'm unfortunately unable to get the error message since the language service crashes on telemetry.

Have you ran into something similar in the past? How did you tackle it? I've read and searched but just can't find a proper way to debug Monaco!


This is the error I recently started to run into:

Uncaught Error: Cannot read properties of null (reading 'sendError')

TypeError: Cannot read properties of null (reading 'sendError')
    at YamlLinks.findLinks (monaco-yaml_yaml__worker__js.js?v=949dc87a:24382:22)
    at Object.findLinks (monaco-yaml_yaml__worker__js.js?v=949dc87a:26547:30)
    at EditorSimpleWorker.fmr (editorSimpleWorker.js:472:64)
    at SimpleWorkerServer._handleMessage (simpleWorker.js:357:65)
    at Object.handleMessage (simpleWorker.js:342:51)
    at SimpleWorkerProtocol._handleRequestMessage (simpleWorker.js:149:38)
    at SimpleWorkerProtocol._handleMessage (simpleWorker.js:118:29)
    at SimpleWorkerProtocol.handleMessage (simpleWorker.js:111:14)
    at SimpleWorkerServer.onmessage (simpleWorker.js:347:24)
    at self.onmessage (chunk-3VE3BF2A.js?v=949dc87a:17:18)
    at errors.js:15:27

It seems to relate to the telemetry which is set to null here:

// src/yaml.worker.ts:57
const languageService = getLanguageService(
    enableSchemaRequest ? schemaRequestService : null,
    null,
    null,
    null,
    null,
  );

Which in turn makes it rather difficult to understand what I'm doing wrong.

WitoDelnat avatar Sep 30 '22 11:09 WitoDelnat

I have noticed this error several times before. It means another (probably more relevant) error occurred which the yaml language service tries to log using telemetry, but it’s stubbed using null. It would be better to add a stub that logs these messages to the console instead.

This would actually be very easy to fix, but the upstream use of a class with private properties instead of an interface makes TypeScript unhappy when trying to use an alternative implementation.

TL;DR: The error is safe to ignore. Also I know how to fix it, but this requires an upstream fix and release.

remcohaszing avatar Sep 30 '22 12:09 remcohaszing

Thanks for the quick response! We'll ignore the error for now.

WitoDelnat avatar Oct 04 '22 09:10 WitoDelnat

@remcohaszing thanks for this great package! I'm also getting this error, but I don't think it's causing a crash - since it's safe to ignore, is there a way to catch this error; it's a little noisy in New Relic?

duggiemitchell avatar Nov 17 '22 13:11 duggiemitchell

Once https://github.com/redhat-developer/yaml-language-server/pull/788 is merged and released, I can get rid of this pesky error (and possibly get the real errors that are supposed to be logged).

remcohaszing avatar Nov 17 '22 13:11 remcohaszing

Wonderful, thanks a bunch!

duggiemitchell avatar Nov 17 '22 13:11 duggiemitchell

@remcohaszing 👋🏾 I see the #788 has been merged in, and following to see if a release with this fix will be coming.

duggiemitchell avatar Jan 26 '23 16:01 duggiemitchell

Released in version 4.0.3 :tada:

remcohaszing avatar Jan 26 '23 17:01 remcohaszing