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

Error: length < 0 in createTextSpan during getApplicableRefactors #20809

Closed
aozgaa opened this issue Dec 19, 2017 · 9 comments
Closed

Error: length < 0 in createTextSpan during getApplicableRefactors #20809

aozgaa opened this issue Dec 19, 2017 · 9 comments
Assignees
Labels
Bug A bug in TypeScript Source: Telemetry The issue relates to the telemetry in editors

Comments

@aozgaa
Copy link
Contributor

aozgaa commented Dec 19, 2017

tsserver version: 2.6.1
Error: length < 0
at createTextSpan (tsserver.js:8817:19)
at Object.createTextSpanFromBounds (tsserver.js:8823:16)
at getErrorSpanForNode (tsserver.js:6264:19)
at createDiagnosticForNodeInSourceFile (tsserver.js:6195:20)
at Object.createDiagnosticForNode (tsserver.js:6191:16)
at checkNode (tsserver.js:77699:36)
at getRangeToExtract (tsserver.js:77655:54)
at Object.getAvailableActions (tsserver.js:77509:38)
at tsserver.js:75017:128
at Object.flatMapIter (tsserver.js:1570:23)
at Object.getApplicableRefactors (tsserver.js:75016:23)
at Object.getApplicableRefactors (tsserver.js:80232:32)
at IOSession.Session.getApplicableRefactors (tsserver.js:86474:53)
at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:85436:61)
at tsserver.js:86669:88
at IOSession.Session.executeWithRequestId (tsserver.js:86660:28)
at IOSession.Session.executeCommand (tsserver.js:86669:33)
at IOSession.Session.onMessage (tsserver.js:86689:35)
at Interface. (tsserver.js:87881:27)
at emitOne (events.js:96:13)
at Interface.emit (events.js:191:7)
at Interface._onLine (readline.js:241:10)
at Interface._normalWrite (readline.js:384:12)
at Socket.ondata (readline.js:101:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:191:7)
at readableAddChunk (_stream_readable.js:178:18)
at Socket.Readable.push (_stream_readable.js:136:10)
at Pipe.onread (net.js:560:20)

@DanielRosenwasser DanielRosenwasser added the Source: Telemetry The issue relates to the telemetry in editors label Dec 19, 2017
@mhegazy mhegazy added the Bug A bug in TypeScript label Jan 20, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Jan 20, 2018
@mhegazy
Copy link
Contributor

mhegazy commented Jan 20, 2018

The Source: Telemetry have limited information. we only have the call stack from the crash report. We need to either mitigate the crash, or add additional asserts to get more information in future crash reports.

@amcasey
Copy link
Member

amcasey commented Jan 23, 2018

@aozgaa Can I assume this is from 2.6.1, like the others?

@amcasey
Copy link
Member

amcasey commented Jan 23, 2018

        var pos = nodeIsMissing(errorNode)
            ? errorNode.pos
            : ts.skipTrivia(sourceFile.text, errorNode.pos);
        return ts.createTextSpanFromBounds(pos, errorNode.end);

It seems plausible that skipTrivia might advance past errorNode.end.

@amcasey
Copy link
Member

amcasey commented Jan 23, 2018

This is the diagnostic we're trying to create:

            if (!isStatement(nodeToCheck) && !(isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) {
                return [createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
            }

@amcasey
Copy link
Member

amcasey commented Jan 24, 2018

nodeIsMissing will only return true if errorNode is undefined (not the case, since we're accessing properties) or if errorNode.pos === errorNode.end. Therefore, if we take that branch, length is guaranteed to be 0 (i.e. no assert).

@aozgaa
Copy link
Contributor Author

aozgaa commented Jan 24, 2018

Yes. All reported issues so far are from 2.6.1. I've updated the description to reflect this.

amcasey added a commit to amcasey/TypeScript that referenced this issue Jan 26, 2018
amcasey added a commit that referenced this issue Jan 31, 2018
@amcasey
Copy link
Member

amcasey commented Feb 21, 2018

Waiting for asserts to be hit (not yet shipped).

@mhegazy mhegazy closed this as completed Mar 10, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
@amcasey
Copy link
Member

amcasey commented Oct 12, 2018

We had a telemetry hit in VS Code 1.28.1 with TS 3.1.1:

Error processing request. Debug Failure. False expression: This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809
Error: Debug Failure. False expression: This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809
    at getErrorSpanForNode (tsserver.js:8839:22)
    at createDiagnosticForNodeInSourceFile (tsserver.js:8752:20)
    at Object.createDiagnosticForNode (tsserver.js:8743:16)
    at checkNode (tsserver.js:111533:36)
    at getRangeToExtract (tsserver.js:111452:53)
    at Object.getAvailableActions (tsserver.js:111260:38)
    at tsserver.js:106434:128
    at getIterator (tsserver.js:535:23)
    at Object.next (tsserver.js:530:35)
    at Object.arrayFrom (tsserver.js:1135:32)
    at Object.getApplicableRefactors (tsserver.js:106433:23)
    at Object.getApplicableRefactors (tsserver.js:115353:32)
    at IOSession.Session.getApplicableRefactors (tsserver.js:122853:53)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:121787:61)
    at tsserver.js:123061:88
    at IOSession.Session.executeWithRequestId (tsserver.js:123052:28)
    at IOSession.Session.executeCommand (tsserver.js:123061:33)
    at IOSession.Session.onMessage (tsserver.js:123081:35)
    at Interface.<anonymous> (tsserver.js:124344:27)
    at emitOne (events.js:116:13)
    at Interface.emit (events.js:211:7)
    at Interface._onLine (readline.js:282:10)
    at Interface._normalWrite (readline.js:424:12)
    at Socket.ondata (readline.js:141:10)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at Pipe.onread (net.js:594:20)

@amcasey amcasey reopened this Oct 12, 2018
@RyanCavanaugh
Copy link
Member

Closing in the absence of a concrete repro

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Source: Telemetry The issue relates to the telemetry in editors
Projects
None yet
Development

No branches or pull requests

5 participants