Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS Code xml extension not working with error UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'editor.autoClosingBrackets' of undefined #12536

Closed
apupier opened this issue Jan 29, 2019 · 7 comments
Assignees
Labels
kind/bug Outline of a bug - must adhere to the bug report template.

Comments

@apupier
Copy link
Contributor

apupier commented Jan 29, 2019

Description

try to use xml features from vs code xml extension vscode:extension/redhat.vscode-xml

Reproduction Steps

  • open command palette
  • use command "Deploy: deploy plugin by id"
  • in log there is:
root INFO unzipping the plugin ProxyPluginDeployerEntry {
  deployer: PluginVsCodeFileHandler { unpackedFolder: '/tmp/vscode-unpacked' },
  delegate:
   PluginDeployerEntryImpl {
     originId: 'vscode:extension/redhat.vscode-xml',
     pluginId: 'vscode:extension/redhat.vscode-xml',
     map: Map {},
     changes: [],
     acceptedTypes: [],
     currentPath: '/tmp/vscode-extension-marketplace/vscode_extension_redhat_vscode_xml.vsix',
     initPath: '/tmp/vscode-extension-marketplace/vscode_extension_redhat_vscode_xml.vsix',
     resolved: true,
     resolvedByName: 'VsCodePluginDeployerResolver' },
  deployerName: 'PluginVsCodeFileHandler' }
root INFO PluginTheiaDirectoryHandler: accepting plugin with path /tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix
root INFO PluginTheiaDirectoryHandler: accepting plugin with path /tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix
root INFO accepting packagejson with engines { vscode: '^1.27.0' }
root INFO HostedPluginServerImpl/ asking to deploy the backend Plugin /tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension and model is { id: 'redhat.vscode-xml',
  name: 'vscode-xml',
  publisher: 'redhat',
  version: '0.3.0',
  displayName: 'XML',
  description: 'XML Language Support by Red Hat',
  engine: { type: 'vscode', version: '^1.27.0' },
  entryPoint:
   { backend: '/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/out/src/extension' },
  contributes:
   { configuration:
      { type: 'object',
        title: 'XML configuration',
        properties: [Object] } } }
root INFO [hosted-plugin: 203] PLUGIN_HOST(203) starting instance

root INFO [hosted-plugin: 203] PLUGIN_HOST(203): PluginManagerExtImpl/init()
PLUGIN_HOST(203): initializing(/home/theia/node_modules/@theia/plugin-ext-vscode/lib/node/plugin-vscode-init.js)

root INFO [hosted-plugin: 203] PLUGIN_HOST(203): PluginManagerExtImpl/loadPlugin(/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/out/src/extension)

root ERROR [hosted-plugin: 203] (node:203) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'editor.autoClosingBrackets' of undefined
    at verifyAutoClosing (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/out/src/extension.js:127:47)
    at didChangeConfiguration (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/out/src/extension.js:59:29)
    at ConfigurationFeature.onDidChangeConfiguration (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/node_modules/vscode-languageclient/lib/client.js:1488:15)
    at ConfigurationFeature.register (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/node_modules/vscode-languageclient/lib/client.js:1449:18)
    at ConfigurationFeature.initialize (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/node_modules/vscode-languageclient/lib/client.js:1435:18)
    at LanguageClient.initializeFeatures (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/node_modules/vscode-languageclient/lib/client.js:2297:21)
    at connection.initialize.then (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/node_modules/vscode-languageclient/lib/client.js:2002:18)
    at <anonymous>
(node:203) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

root ERROR [hosted-plugin: 203] (node:203) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

OS and version:

windows
docker run -it -p 3000:3000 -v "C:/Users/Aurelien Pupier/theia:/home/project:cached" theiaide/theia-full:0.3.18

Diagnostics:

@vrubezhny
Copy link
Contributor

The configurationDefaults object of rawPlugin.contributes is not read and not added into configuration, so I did changed the code as follows in order to initialize it:

-------------- packages/plugin-ext/src/common/plugin-protocol.ts --------------
index 33f03db5..45c9dbbf 100644
@@ -63,6 +63,8 @@ export interface PluginPackageContribution {
     keybindings?: PluginPackageKeybinding[];
     debuggers?: PluginPackageDebuggersContribution[];
     snippets: PluginPackageSnippetsContribution[];
+   // tslint:disable-next-line:no-any
+    configurationDefaults?: { [location: string]: any };
 }
 
 export interface PluginPackageViewContainer {
@@ -344,6 +346,8 @@ export interface PluginContribution {
     keybindings?: Keybinding[];
     debuggers?: DebuggerContribution[];
     snippets?: SnippetContribution[];
+   // tslint:disable-next-line:no-any
+    configurationDefaults?: { [location: string]: any };
 }
 
 export interface SnippetContribution {

-------- packages/plugin-ext/src/hosted/node/scanners/scanner-theia.ts --------
index b5f31f16..652fffbd 100644
@@ -169,8 +169,16 @@ export class TheiaPluginScanner implements PluginScanner {
             const debuggers = this.readDebuggers(rawPlugin.contributes.debuggers!);
             contributions.debuggers = debuggers;
         }
+        if (rawPlugin.contributes!.configurationDefaults) {
+            const configurationDefaults = this.readConfigurationDefaults(rawPlugin.contributes.configurationDefaults!);
+            contributions.configurationDefaults = configurationDefaults;
+        }
 
         contributions.snippets = this.readSnippets(rawPlugin);
+        console.info('==>> readContributions() ==>>');
+        console.log(contributions);
+        console.info('<<== readContributions() <<==');
+
         return contributions;
     }
 
@@ -213,6 +221,12 @@ export class TheiaPluginScanner implements PluginScanner {
         };
     }
 
+    // tslint:disable-next-line:no-any
+    private readConfigurationDefaults(rawConfigurationDefaults: any): any {
+        console.info('readConfigurationDefaults() : [' + rawConfigurationDefaults + ']');
+        return rawConfigurationDefaults;
+    }
+
     private readKeybinding(rawKeybinding: PluginPackageKeybinding): Keybinding {
         return {
             keybinding: rawKeybinding.key,

So, now I have configuration object like the following:

root INFO ==>> readContributions() ==>>
root INFO { configuration: 
   { type: 'object',
     title: 'XML configuration',
     properties: 
      { 'xml.trace.server': [Object],
        'xml.catalogs': [Object],
        'xml.logs.client': [Object],
        'xml.format.splitAttributes': [Object],
        'xml.format.joinCDATALines': [Object],
        'xml.format.joinContentLines': [Object],
        'xml.format.joinCommentLines': [Object],
        'xml.format.spaceBeforeEmptyCloseTag': [Object],
        'xml.format.enabled': [Object],
        'xml.fileAssociations': [Object],
        'xml.completion.autoCloseTags': [Object],
        'xml.server.vmargs': [Object],
        'xml.validation.noGrammar': [Object],
        'xml.validation.enabled': [Object],
        'xml.validation.schema': [Object] } },
  configurationDefaults: { '[xml]': { 'editor.autoClosingBrackets': 'never' } },
  snippets: undefined }
root INFO <<== readContributions() <<==

But despite of this, later in the log I see the same error:

root INFO Deploying backend plugin "vscode-xml@0.3.0" from "/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/out/src/extension"
root INFO [hosted-plugin: 11241] PLUGIN_HOST(11241) starting instance

root INFO [hosted-plugin: 11241] PLUGIN_HOST(11241): PluginManagerExtImpl/init()

root INFO [hosted-plugin: 11241] PLUGIN_HOST(11241): initializing(/home/jeremy/projects/che/source/theia-ide/theia/packages/plugin-ext-vscode/lib/node/plugin-vscode-init.js)

root INFO [hosted-plugin: 11241] PLUGIN_HOST(11241): PluginManagerExtImpl/loadPlugin(/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/out/src/extension)

root ERROR [hosted-plugin: 11241] (node:11241) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'editor.autoClosingBrackets' of undefined
    at verifyAutoClosing (/tmp/vscode-unpacked/vscode_extension_redhat_vscode_xml.vsix/extension/out/src/extension.js:127:47)
 ...

So, it looks like I'm doing something wrong and my configurationDefaults is either not accepted by or not passed to plug-in's verifyAutoClosing...

@vrubezhny
Copy link
Contributor

Depends on eclipse-theia/theia#3540

@apupier
Copy link
Contributor Author

apupier commented Apr 10, 2019

@vrubezhny eclipse-theia/theia#3540 is marked as fixed. Can we close this issue then? or more work is required? or not yet available in the Che version?

@apupier
Copy link
Contributor Author

apupier commented Apr 10, 2019

seems there is still a notification error:

image

even if the xml extension is installed and seems to work

@tsmaeder
Copy link
Contributor

tsmaeder commented May 2, 2019

Need to understand why we get the notification and whether it is harmless.

@tolusha
Copy link
Contributor

tolusha commented May 6, 2019

It is a warning showing that several settings are responsible for the save action.
https://github.com/redhat-developer/vscode-xml/blob/master/src/extension.ts#L139

function verifyAutoClosing() {
  let configXML = workspace.getConfiguration();
  let closeTags = configXML.get("xml.completion.autoCloseTags");
  let closeBrackets = configXML.get("[xml]")["editor.autoClosingBrackets"];
  if (closeTags && closeBrackets != "never") {
    window.showWarningMessage(
      "The [xml].editor.autoClosingBrackets setting conflicts with xml.completion.autoCloseTags. It's recommended to disable it.",
      "Disable",
      "Ignore").then((selection) => {
        if (selection == "Disable") {
          let scopeInfo : ScopeInfo = getScopeLevel("", "[xml]");
          workspace.getConfiguration().update("[xml]", { "editor.autoClosingBrackets": "never" }, scopeInfo.configurationTarget).then(
            () => console.log('[xml].editor.autoClosingBrackets globally set to never'),
            (error) => console.log(error)
          );
        }
        else if(selection == "Ignore") {
          ignoreAutoCloseTags = true;
        }
      });
  }
}

@tolusha
Copy link
Contributor

tolusha commented May 6, 2019

But the warning itself shouldn't be shown because closeBrackets is undefined.
So, it should be

if (closeTags && closeBrackets && closeBrackets != "never") {

@tolusha tolusha self-assigned this May 15, 2019
@tolusha tolusha added kind/bug Outline of a bug - must adhere to the bug report template. team/languages labels May 15, 2019
@tolusha tolusha closed this as completed May 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Outline of a bug - must adhere to the bug report template.
Projects
None yet
Development

No branches or pull requests

4 participants