Skip to content

TypeError: Cannot read property 'length' of undefined in 'Object.find' during 'getApplicableRefactors' #21793

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

Closed
aozgaa opened this issue Feb 9, 2018 · 5 comments
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Source: Telemetry The issue relates to the telemetry in editors

Comments

@aozgaa
Copy link
Contributor

aozgaa commented Feb 9, 2018

This issue comes from crash dumps in telemetry. We've tried to de-duplicate issues on a best-effort basis, comparing the sequence of methods called and the command requested while ignoring line numbers.
TypeScript Version Prefix: 2.7.1
VSCode Version 1.20.0-insider
command requested: getApplicableRefactors
hitting sessions: 3195
proportion of all sessions: 0.01192729390420087
five line hash: 5916f9b992b55808646d21adefdcc25c
stack

TypeError: Cannot read property 'length' of undefined
    at Object.find (tsserver.js:1523:34)
    at recordUsagebySymbol (tsserver.js:81559:41)
    at recordUsage (tsserver.js:81528:36)
    at collectUsages (tsserver.js:81521:25)
    at visitNode (tsserver.js:12595:24)
    at Object.forEachChild (tsserver.js:12958:24)
    at collectUsages (tsserver.js:81524:28)
    at visitNode (tsserver.js:12595:24)
    at Object.forEachChild (tsserver.js:12949:24)
    at collectUsages (tsserver.js:81524:28)
    at visitNode (tsserver.js:12595:24)
    at Object.forEachChild (tsserver.js:12776:24)
    at collectUsages (tsserver.js:81524:28)
    at visitNode (tsserver.js:12595:24)
    at Object.forEachChild (tsserver.js:12807:24)
    at collectUsages (tsserver.js:81524:28)
    at visitNodes (tsserver.js:12604:30)
    at Object.forEachChild (tsserver.js:12796:24)
    at collectUsages (tsserver.js:81524:28)
    at collectReadsAndWrites (tsserver.js:81397:17)
    at getPossibleExtractionsWorker (tsserver.js:80843:38)
    at getPossibleExtractions (tsserver.js:80800:26)
    at Object.getAvailableActions (tsserver.js:80399:35)
    at unknown (tsserver.js:77085:128)
    at getIterator (tsserver.js:1733:23)
    at Object.next (tsserver.js:1728:35)
    at Object.arrayFrom (tsserver.js:2267:32)
    at Object.getApplicableRefactors (tsserver.js:77084:23)
    at Object.getApplicableRefactors (tsserver.js:83299:32)
    at IOSession.Session.getApplicableRefactors (tsserver.js:90156:53)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:89112:61)
    at unknown (tsserver.js:90355:88)
    at IOSession.Session.executeWithRequestId (tsserver.js:90346:28)
    at IOSession.Session.executeCommand (tsserver.js:90355:33)
    at IOSession.Session.onMessage (tsserver.js:90375:35)
    at Interface.<anonymous> (tsserver.js:91576: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)
@aozgaa aozgaa added the Source: Telemetry The issue relates to the telemetry in editors label Feb 9, 2018
@mhegazy mhegazy added the Bug A bug in TypeScript label Feb 9, 2018
@mhegazy mhegazy added this to the TypeScript 2.8 milestone Feb 9, 2018
@amcasey
Copy link
Member

amcasey commented Feb 9, 2018

@aozgaa These line numbers don't seem to be lining up with the file from npm install typescript@2.7.1.

@amcasey
Copy link
Member

amcasey commented Feb 9, 2018

Without line numbers, this is just a guess: I believe symbol.getDeclarations() is returning undefined on this line
const declInFile = find(symbol.getDeclarations(), d => d.getSourceFile() === sourceFile);

@amcasey
Copy link
Member

amcasey commented Feb 9, 2018

Looks like that's expected (getDeclarations(): Declaration[] | undefined) and find doesn't handle undefined.

@amcasey
Copy link
Member

amcasey commented Feb 9, 2018

Prototype properties don't have declarations.

amcasey added a commit to amcasey/TypeScript that referenced this issue Feb 9, 2018
amcasey added a commit to amcasey/TypeScript that referenced this issue Feb 10, 2018
amcasey added a commit to amcasey/TypeScript that referenced this issue Feb 10, 2018
@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Feb 10, 2018
@aozgaa
Copy link
Contributor Author

aozgaa commented Mar 5, 2018

This issue reproduced in the following context:
TypeScript Version Prefix: 2.7.2
VSCode Version 1.20.1
command requested: getApplicableRefactors
hitting sessions: 466
proportion of all sessions: 0.009567020468496583
stack

TypeError: Cannot read property 'length' of undefined
    at Object.find (tsserver.js:1524:34)
    at recordUsagebySymbol (tsserver.js:81757:41)
    at recordUsage (tsserver.js:81726:36)
    at collectUsages (tsserver.js:81719:25)
    at visitNode (tsserver.js:12623:24)
    at Object.forEachChild (tsserver.js:12770:24)
    at collectUsages (tsserver.js:81707:28)
    at visitNode (tsserver.js:12623:24)
    at Object.forEachChild (tsserver.js:12696:21)
    at collectUsages (tsserver.js:81722:28)
    at visitNodes (tsserver.js:12632:30)
    at Object.forEachChild (tsserver.js:12833:24)
    at collectUsages (tsserver.js:81722:28)
    at visitNode (tsserver.js:12623:24)
    at Object.forEachChild (tsserver.js:12847:24)
    at collectUsages (tsserver.js:81722:28)
    at visitNodes (tsserver.js:12632:30)
    at Object.forEachChild (tsserver.js:12824:24)
    at collectUsages (tsserver.js:81722:28)
    at visitNode (tsserver.js:12623:24)
    at Object.forEachChild (tsserver.js:12731:21)
    at collectUsages (tsserver.js:81722:28)
    at visitNode (tsserver.js:12623:24)
    at Object.forEachChild (tsserver.js:12806:21)
    at collectUsages (tsserver.js:81722:28)
    at visitNode (tsserver.js:12623:24)
    at Object.forEachChild (tsserver.js:12696:21)
    at collectUsages (tsserver.js:81722:28)
    at visitNodes (tsserver.js:12632:30)
    at Object.forEachChild (tsserver.js:12833:24)
    at collectUsages (tsserver.js:81722:28)
    at visitNode (tsserver.js:12623:24)
    at Object.forEachChild (tsserver.js:12831:21)
    at collectUsages (tsserver.js:81722:28)
    at visitNodes (tsserver.js:12632:30)
    at Object.forEachChild (tsserver.js:12824:24)
    at collectUsages (tsserver.js:81722:28)
    at collectReadsAndWrites (tsserver.js:81595:17)
    at getPossibleExtractionsWorker (tsserver.js:81041:38)
    at getPossibleExtractions (tsserver.js:80998:26)
    at Object.getAvailableActions (tsserver.js:80597:35)
    at unknown (tsserver.js:77283:128)
    at getIterator (tsserver.js:1734:23)
    at Object.next (tsserver.js:1729:35)
    at Object.arrayFrom (tsserver.js:2268:32)
    at Object.getApplicableRefactors (tsserver.js:77282:23)
    at Object.getApplicableRefactors (tsserver.js:83497:32)
    at IOSession.Session.getApplicableRefactors (tsserver.js:90354:53)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:89310:61)
    at unknown (tsserver.js:90553:88)
    at IOSession.Session.executeWithRequestId (tsserver.js:90544:28)
    at IOSession.Session.executeCommand (tsserver.js:90553:33)
    at IOSession.Session.onMessage (tsserver.js:90573:35)
    at Interface.<anonymous> (tsserver.js:91774: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)

@microsoft microsoft locked and limited conversation to collaborators Jul 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue Source: Telemetry The issue relates to the telemetry in editors
Projects
None yet
Development

No branches or pull requests

3 participants