microsoft/azure-pipelines-vscode

Language server keeps crashing

forbushbl opened this issue · 6 comments

For some reason, the language server keeps crashing which prevents the extension from starting up. This is the error that I see printed in the console each time it crashes:

/Users/[REDACTED]/.vscode/extensions/ms-azure-devops.azure-pipelines-1.191.0/dist/server.js:2
module.exports=(()=>{var e={29541:(e,t,n)=>{"use strict";n(98705);const r=n(31669).inherits,i=n(76021),o=n(28614).EventEmitter;function s(e,t){if(!(this instanceof s))return new s(e,t);o.call(this),this._promisifiedCallback=!1;let n=t;"function"==typeof e?this.callback=e:e&&(n=e),this.timeout=n&&n.timeout||null,this.options=n}e.exports=s,r(s,o),s.prototype.callback=function(e,t){throw new Error('"agent-base" has no default implementation, you must subclass and override `callback()`')},s.prototype.addRequest=function(e,t){const n=Object.assign({},t);null==n.host&&(n.host="localhost"),null==n.port&&(n.port=n.secureEndpoint?443:80);const r=Object.assign({},this.options,n);let o;r.host&&r.path&&delete r.path,delete r.agent,delete r.hostname,delete r._defaultAgent,delete r.defaultPort,delete r.createConnection,e._last=!0,e.shouldKeepAlive=!1;let s=!1;const a=this.timeout,u=this.freeSocket;function c(t){e._hadError||(e.emit("error",t),e._hadError=!0)}function l(e){s||(null!=o&&(clearTimeout(o),o=null),c(e))}!this._promisifiedCallback&&this.callback.length>=3&&(this.callback=i(this.callback,this),this._promisifiedCallback=!0),a>0&&(o=setTimeout((function(){o=null,s=!0;const e=new Error('A "socket" was not created for HTTP request before '+a+"ms");e.code="ETIMEOUT",c(e)}),a));try{Promise.resolve(this.callback(e,r)).then((function(t){var n;s||(null!=o&&(clearTimeout(o),o=null),(n=t)&&"function"==typeof n.addRequest?t.addRequest(e,r):t?(t.on("free",(function(){u(t,r)})),e.onSocket(t)):c(new Error("no Duplex stream was returned to agent-base for `"+e.method+" "+e.path+"`")))}),l)}catch(e){Promise.reject(e).catch(l)}},s.prototype.freeSocket=function(e,t){e.destroy()}},98705:(e,t,n)=>{"use strict";const r=n(78835),i=n(57211),o="__agent_base_https_request_patched__";var s;i.request[o]||(i.request=(s=i.request,function(e,t){let n;return n="string"==typeof e?r.parse(e):Object.assign({},e),null==n.port&&(n.port=443),n.secureEndpoint=!0,s.call(i,n,t)}),i.request[o]=!0),i.get=function(e,t,n){let o;"string"==typeof e&&t&&"function"!=typeof t?o=Object.assign({},r.parse(e),t):t||n?n||(o=e,n=t):o=e;const s=i.request(o,n);return s.end(),s}},80938:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.customLanguageService=t.KEDGE_SCHEMA_URL=t.KUBERNETES_SCHEMA_URL=void 0;const r=n(68212),i=n(96813),o=n(42775),s=n(85622),a=n(35747),u=n(17373),c=n(78835),l=n(18472),h=n(13337),p=n(13337),d=n(13337),f=n(13337),m=n(13337),g=n(13337);var v,y,x,C,b;l.config(process.env.VSCODE_NLS_CONFIG),function(e){e.type=new r.NotificationType("json/schemaAssociations")}(v||(v={})),function(e){e.type=new r.RequestType("vscode/content")}(y||(y={})),function(e){e.type=new r.RequestType("custom/schema/content")}(x||(x={})),function(e){e.type=new r.RequestType("custom/schema/request")}(C||(C={})),function(e){e.type=new r.RequestType("json/colorSymbols")}(b||(b={}));let D=null;D=-1==process.argv.indexOf("--stdio")?r.createConnection(r.ProposedFeatures.all):r.createConnection(),console.log=D.console.log.bind(D.console),console.error=D.console.error.bind(D.console);let S=new r.TextDocuments(i.TextDocument);S.listen(D);let E,A,w=!1,k=!1,F=[];D.onInitialize((e=>(E=e.capabilities,F=e.workspaceFolders,A=u.URI.parse(e.rootPath),k=E.workspace&&!!E.workspace.workspaceFolders,w=function(...t){let n=e.capabilities;for(let e=0;n&&e<t.length;e++)n=n[t[e]];return!!n}("textDocument","formatting","dynamicRegistration"),{capabilities:{textDocumentSync:r.TextDocumentSyncKind.Full,completionProvider:{resolveProvider:!0},hoverProvider:!0,documentSymbolProvider:!0,documentFormattingProvider:!1}})));let T,P,R={resolveRelativePath:(e,t)=>c.resolve(t,e)};t.KUBERNETES_SCHEMA_URL="https://gist.githubusercontent.com/JPinkney/ccaf3909ef811e5657ca2e2e1fa05d76/raw/f85e51bfb67fdb99ab7653c2953b60087cc871ea/openshift_schema_all.json",t.KEDGE_SCHEMA_URL="https://raw.githubusercontent.com/kedgeproject/json-schema/master/master/kedge-json-schema.json",t.customLanguageService=d.getLanguageService((e=>{if(k)for(let t in F){let n=F[t],r=n.uri,i=n.name,o=new RegExp("^(?:[a-z]+:)?//","i");if(-1!==e.indexOf(i)&&!e.match(o)){let t=r.split(i)[0],n=e.split(i);n.shift(),e=t+i+n.join(i)}}if(h.startsWith(e,"file://")){let t=u.URI.parse(e).fsPath;return new Promise(((e,n)=>{a.readFile(t,"UTF-8",((t,r)=>{t?n(""):e(g.ParseSchema(r.toString()))}))}))}if(h.startsWith(e,"vscode://"))return D.sendRequest(y.type,e).then((e=>e),(e=>e.message));{let t=u.URI.parse(e).scheme.toLowerCase();if("http"!==t&&"https"!==t)return D.sendRequest(x.type,e).then((e=>g.ParseSchema(e)))}return-1!==e.indexOf("//schema.management.azure.com/")&&D.telemetry.logEvent({key:"json.schema",value:{schemaURL:e}}),o.xhr({url:e,followRedirects:5,headers:{"Accept-Encoding":"gzip, deflate"}}).then((e=>g.ParseSchema(e.responseText)),(e=>Promise.reject(e.responseText||o.getErrorStatusDescription(e.status)||e.toString())))}),[],(e=>D.sendRequest(C.type,e)),R);let _=null,O=[],N=[],M=[],I=[];function j(){let e={validate:!0,schemas:[],customTags:I};if(P)for(var n in P){let t=P[n];Array.isArray(t)&&t.forEach((t=>{e=L(t,[n],null,e)}))}N&&N.forEach((t=>{let n=t.url;!n&&t.schema&&(n=t.schema.id),!n&&t.fileMatch&&(n="vscode://schemas/custom/"+encodeURIComponent(t.fileMatch.join("&"))),n&&("."===n[0]&&A&&!k&&(n=u.URI.file(s.normalize(s.join(A.fsPath,n))).toString()),e=L(n,t.fileMatch,t.schema,e))})),M&&(e.schemas=e.schemas.concat(M)),t.customLanguageService.configure(e),S.all().forEach(z)}function L(e,n,r,i){return"kubernetes"===e.toLowerCase().trim()&&(e=t.KUBERNETES_SCHEMA_URL),"kedge"===e.toLowerCase().trim()&&(e=t.KEDGE_SCHEMA_URL),null===r?i.schemas.push({uri:e,fileMatch:n}):i.schemas.push({uri:e,fileMatch:n,schema:r}),n.constructor===Array&&e===t.KUBERNETES_SCHEMA_URL?n.forEach((e=>{O.push(e)})):e===t.KUBERNETES_SCHEMA_URL&&O.push(n),i}function B(e,t){for(let n in e)e[n].configureSettings({isKubernetes:t})}function q(e){for(let t in O){let n=O[t];if(new f.FilePatternAssociation(n).matchesPattern(e.uri))return!0}return!1}D.onDidChangeConfiguration((e=>{var t=e.settings;o.configure(t.http&&t.http.proxy,t.http&&t.http.proxyStrictSSL),O=[],T=t.yaml&&t.yaml.schemas,N=[],I=t.yaml&&t.yaml.customTags?t.yaml.customTags:[];for(let e in T){let t=T[e],n={fileMatch:Array.isArray(t)?t:[t],url:e};N.push(n)}j(),w&&(t&&t.yaml&&t.yaml.format&&t.yaml.format.enable?_||(_=D.client.register(r.DocumentFormattingRequest.type,{documentSelector:[{language:"yaml"}]})):_&&(_.then((e=>e.dispose())),_=null))})),D.onNotification(v.type,(e=>{P=e,O=[],j()})),S.onDidChangeContent((e=>{z(e.document)})),S.onDidClose((e=>{W(e.document),D.sendDiagnostics({uri:e.document.uri,diagnostics:[]})}));let U={};function W(e){let t=U[e.uri];t&&(clearTimeout(t),delete U[e.uri])}function z(e){W(e),U[e.uri]=setTimeout((()=>{delete U[e.uri],V(e)}),200)}function V(e){if(!e)return;if(0===e.getText().length)return void D.sendDiagnostics({uri:e.uri,diagnostics:[]});let n=m.parse(e.getText(),I);q(e)?B(n.documents,!0):B(n.documents,!1),t.customLanguageService.doValidation(e,n).then((function(t){let n=[];for(let e in t)n.push(t[e]);D.sendDiagnostics({uri:e.uri,diagnostics:p.removeDuplicatesObj(n)})}),(function(e){}))}D.onDidChangeWatchedFiles((e=>{let n=!1;e.changes.forEach((e=>{t.customLanguageService.resetSchema(e.uri)&&(n=!0)})),n&&S.all().forEach(V)})),D.onCompletion((e=>{let n=S.get(e.textDocument.uri);if(!n)return Promise.resolve({items:[],isIncomplete:!1});let r=p.completionHelper(n,e.position).newText,i=m.parse(r);return q(n)?B(i.documents,!0):B(i.documents,!1),t.customLanguageService.doComplete(n,e.position,i)})),D.onCompletionResolve((e=>t.customLanguageService.doResolve(e))),D.onHover((e=>{let n=S.get(e.textDocument.uri);if(!n)return Promise.resolve(void 0);let r=m.parse(n.getText());return q(n)?B(r.documents,!0):B(r.documents,!1),t.customLanguageService.doHover(n,e.position,r)})),D.onDocumentSymbol((e=>{let n=S.get(e.textDocument.uri);if(!n)return;let r=m.parse(n.getText());return t.customLanguageService.findDocumentSymbols(n,r)})),D.onDocumentFormatting((e=>{let n=S.get(e.textDocument.uri);if(n)return t.customLangu
[Info  - 1:45:11 PM] Connection to server got closed. Server will restart.
[Error - 1:45:11 PM] Request textDocument/documentSymbol failed.
  Message: Request textDocument/documentSymbol failed with message: Cannot read property 'length' of undefined
  Code: -32603 

@forbushbl is the pipeline YAML you're working on something that you can share publicly? If not, can you try isolating the issue by removing parts of the pipeline definition until the server stops crashing?

# File: start.yml
parameters:
  - name: buildSteps # the name of the parameter is buildSteps
    type: stepList # data type is StepList
    default: [] # default value of buildSteps
  stages:
  - stage: secure_buildstage
    pool: Hosted VS2017
    jobs:
    - job: secure_buildjob
      steps:
      - script: echo This happens before code 
        displayName: 'Base: Pre-build'
      - script: echo Building
        displayName: 'Base: Build'
  
      - ${{ each step in parameters.buildSteps }}:
        - ${{ each pair in step }}:
            ${{ if ne(pair.value, 'CmdLine@2') }}:
              ${{ pair.key }}: ${{ pair.value }}       
            ${{ if eq(pair.value, 'CmdLine@2') }}: 
              '${{ pair.value }}': error         
  
      - script: echo This happens after code
        displayName: 'Base: Signing'

here is one example that produces similar crash. Direct copy paste from https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#extend-from-a-template

Some crashlog

Starting inspector on 127.0.0.1:6009 failed: address already in use
/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:175
    for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
                                                   ^

TypeError: Cannot read property 'length' of undefined
    at addItemsToArrayNode (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:175:52)
    at addItemsToArrayNode (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:192:21)
    at addItemsToArrayNode (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:192:21)
    at recursivelyBuildAst (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:100:13)
    at recursivelyBuildAst (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:92:48)
    at addPropertiesToObjectNode (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:169:30)
    at recursivelyBuildAst (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:80:13)
    at addItemsToArrayNode (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:198:28)
    at recursivelyBuildAst (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:100:13)
    at recursivelyBuildAst (/Users/janne.kujanpaa/src/azure-pipelines-language-server/language-service/lib/parser/yamlParser.js:92:48)
[Info  - 6:41:10 PM] Connection to server got closed. Server will restart.

Thanks @jikuja, I think I already have a fix for this ready to be published, but I'll check later just in case (and finally get that release out...).

This was a new bug. Thanks for reporting!

1.194.0 has been released and should stop the crashing :).

Wait, I forgot to include the actual changes... 🤦
Just released 1.194.1 with the real fixes.