Skip to content

Crash on invoking function signature. #1045

Description

@hifall

monaco-editor version: 0.14.3
Browser: Chrome 67.0.3396.99
OS: macOS 10.12

Okay, it seems like a VS Code issue from where the crash happens, but since I am using Monaco, I am filing it here.

I am using Monaco editor connected with a backend language server. When trying to invoke displaying the signature of a function, I am seeing a crash with the following call stack in the browser console:

errors.js:58 Uncaught Error: Cannot read property 'length' of undefined

TypeError: Cannot read property 'length' of undefined
    at ParameterHintsWidget.render (parameterHintsWidget.js:272)
    at parameterHintsWidget.js:182
    at Emitter.fire (event.js:105)
    at parameterHintsWidget.js:104
    at ParameterHintsWidget.render (parameterHintsWidget.js:272)
    at parameterHintsWidget.js:182
    at Emitter.fire (event.js:105)
    at parameterHintsWidget.js:104
    at errors.js:58

The Monaco client sends a request like this:

{"jsonrpc":"2.0","id":6,"method":"textDocument/signatureHelp","params":{"textDocument":{"uri":"/home/model.r"},"position":{"line":36,"character":6}}}

And the language server responds with:

{"jsonrpc":"2.0","id":6,"result":{"signatures":[{"label":"paste(..., sep = \" \", collapse = NULL)"}],"activeSignature":0}}

This happens because of the following line inside ParameterHintsWidget's render function:

var hasParameters = signature.parameters.length > 0;

This line assumes that parameters field always present inside signature, while in fact parameters is absent from the server response above. However, the LSP specification says SignatureInformation's parameters is optional. Therefore, the assumption doesn't seem correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions