Typescript: Definitions stop working after a while

Created on 7 Oct 2019  路  25Comments  路  Source: microsoft/TypeScript

Template info added by @mjbvz

TypeScript Version: 3.7.0-dev.20191013

Search Terms

  • go to definition
  • react

Issue Type: Bug

Open VSCode, open a React file (JS or JSX), and on hovering a class or any other element on the code, a definition popup shows up correctly.

After a while (it can be minutes, or just by editing a file), it stops working and all it shows up on hovering is a small "Loading..." tooltip.

image

And I was able to grab this from the app's console:

/C:/Users/MuTLY/AppData/Local/Programs/Microsoft VS Code/resources/app/out/vs/workbench/workbench.desktop.main.js:3579 [Extension Host] debugger listening on port 58674
log.ts:173   ERR <semantic> TypeScript Server Error (3.6.2)
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at Object.find (tsserver.js:385:35)
    at getReferencedSymbolsForModuleIfDeclaredBySourceFile (tsserver.js:105629:78)
    at Object.getReferencedSymbolsForNode (tsserver.js:105607:40)
    at Object.getReferenceEntriesForNode (tsserver.js:105341:58)
    at getSemanticDocumentHighlights (tsserver.js:104031:57)
    at Object.getDocumentHighlights (tsserver.js:104019:20)
    at Object.getDocumentHighlights (tsserver.js:125577:42)
    at IOSession.Session.getDocumentHighlights (tsserver.js:134328:71)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:133752:61)
    at tsserver.js:135178:88
    at IOSession.Session.executeWithRequestId (tsserver.js:135169:28)
    at IOSession.Session.executeCommand (tsserver.js:135178:33)
    at IOSession.Session.onMessage (tsserver.js:135201:35)
    at Interface.<anonymous> (tsserver.js:136516:27)
    at Interface.emit (events.js:182:13)
    at Interface._onLine (readline.js:290:10)
    at Interface._normalWrite (readline.js:433:12)
    at Socket.ondata (readline.js:149:10)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17): Error: <semantic> TypeScript Server Error (3.6.2)
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at Object.find (tsserver.js:385:35)
    at getReferencedSymbolsForModuleIfDeclaredBySourceFile (tsserver.js:105629:78)
    at Object.getReferencedSymbolsForNode (tsserver.js:105607:40)
    at Object.getReferenceEntriesForNode (tsserver.js:105341:58)
    at getSemanticDocumentHighlights (tsserver.js:104031:57)
    at Object.getDocumentHighlights (tsserver.js:104019:20)
    at Object.getDocumentHighlights (tsserver.js:125577:42)
    at IOSession.Session.getDocumentHighlights (tsserver.js:134328:71)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:133752:61)
    at tsserver.js:135178:88
    at IOSession.Session.executeWithRequestId (tsserver.js:135169:28)
    at IOSession.Session.executeCommand (tsserver.js:135178:33)
    at IOSession.Session.onMessage (tsserver.js:135201:35)
    at Interface.<anonymous> (tsserver.js:136516:27)
    at Interface.emit (events.js:182:13)
    at Interface._onLine (readline.js:290:10)
    at Interface._normalWrite (readline.js:433:12)
    at Socket.ondata (readline.js:149:10)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    at Function.create (c:\Users\MuTLY\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:53:63463)
    at h.dispatchResponse (c:\Users\MuTLY\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:53:56618)
    at h.dispatchMessage (c:\Users\MuTLY\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:53:55516)
    at constructor._reader.onData.e (c:\Users\MuTLY\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:53:54992)
    at u.fire (c:\Users\MuTLY\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:50:207)
    at t.Reader.onLengthData (c:\Users\MuTLY\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:53:61683)
    at Socket.t.Reader.constructor.e.on.e (c:\Users\MuTLY\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\typescript-language-features\dist\extension.js:53:61331)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

I have to mention I already uninstalled and reinstalled VSCode a few times, even going thru the lengths of manually deleting folders and Registry keys as explained in several other issues here.

VS Code version: Code 1.38.1 (b37e54c98e1a74ba89e03073e5a3761284e3ffb0, 2019-09-11T13:35:15.005Z)
OS version: Windows_NT x64 10.0.18362


System Info

|Item|Value|
|---|---|
|CPUs|Intel(R) Core(TM) i5-7300HQ CPU @ 2.50GHz (4 x 2496)|
|GPU Status|2d_canvas: enabled
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
oop_rasterization: disabled_off
protected_video_decode: enabled
rasterization: enabled
skia_deferred_display_list: disabled_off
skia_renderer: disabled_off
surface_synchronization: enabled_on
video_decode: enabled
viz_display_compositor: disabled_off
webgl: enabled
webgl2: enabled|
|Load (avg)|undefined|
|Memory (System)|7.87GB (1.27GB free)|
|Process Argv||
|Screen Reader|no|
|VM|0%|

Extensions (3)

Extension|Author (truncated)|Version
---|---|---
beautify|Hoo|1.5.0
subtle-brackets|raf|3.0.0
highlight-matching-tag|vin|0.9.5


Bug

All 25 comments

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

Please try upgrading your workspace to use typescript@next by installing this extension.

Do you still see the issue after upgrading?

Hello @mjbvz - I'm going to try that and get back to you asap.

@mjbvz , after using the typescript@next for a while, the same issue happened.

This is the developer log:

extensionHost.ts:295 [Extension Host] debugger listening on port 10353
console.ts:137 [Extension Host] (node:29573) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
log.ts:196   ERR <syntax> TypeScript Server Error (3.7.0-dev.20191009)
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at Object.unescapeLeadingUnderscores (tsserver.js:14522:19)
    at tryGetName (tsserver.js:112613:27)
    at compareChildren (tsserver.js:112599:78)
    at Array.sort (native)
    at sortChildren (tsserver.js:112596:22)
    at endNode (tsserver.js:112179:17)
    at addNodeWithRecursiveChild (tsserver.js:112187:13)
    at addChildrenRecursively (tsserver.js:112268:25)
    at visitNodes (tsserver.js:17542:30)
    at Object.forEachChild (tsserver.js:17782:24)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNode (tsserver.js:17533:24)
    at Object.forEachChild (tsserver.js:17780:21)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNodes (tsserver.js:17542:30)
    at Object.forEachChild (tsserver.js:17773:24)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNode (tsserver.js:17533:24)
    at Object.forEachChild (tsserver.js:17663:21)
    at addChildrenRecursively (tsserver.js:112264:28)
    at visitNodes (tsserver.js:17542:30)
    at Object.forEachChild (tsserver.js:17782:24)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNode (tsserver.js:17533:24)
    at Object.forEachChild (tsserver.js:17780:21)
    at addChildrenRecursively (tsserver.js:112413:24)
    at rootNavigationBarNode (tsserver.js:112117:17)
    at Object.getNavigationTree (tsserver.js:112083:38)
    at Object.getNavigationTree (tsserver.js:130754:37)
    at IOSession.Session.getNavigationTree (tsserver.js:140231:44)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:139125:61)
    at tsserver.js:140562:88
    at IOSession.Session.executeWithRequestId (tsserver.js:140553:28)
    at IOSession.Session.executeCommand (tsserver.js:140562:33)
    at IOSession.Session.onMessage (tsserver.js:140585:35)
    at Interface.<anonymous> (tsserver.js:141900:27)
    at Interface.emit (events.js:182:13)
    at Interface._onLine (readline.js:290:10)
    at Interface._normalWrite (readline.js:433:12)
    at Socket.ondata (readline.js:149:10)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17): Error: <syntax> TypeScript Server Error (3.7.0-dev.20191009)
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
    at Object.unescapeLeadingUnderscores (tsserver.js:14522:19)
    at tryGetName (tsserver.js:112613:27)
    at compareChildren (tsserver.js:112599:78)
    at Array.sort (native)
    at sortChildren (tsserver.js:112596:22)
    at endNode (tsserver.js:112179:17)
    at addNodeWithRecursiveChild (tsserver.js:112187:13)
    at addChildrenRecursively (tsserver.js:112268:25)
    at visitNodes (tsserver.js:17542:30)
    at Object.forEachChild (tsserver.js:17782:24)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNode (tsserver.js:17533:24)
    at Object.forEachChild (tsserver.js:17780:21)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNodes (tsserver.js:17542:30)
    at Object.forEachChild (tsserver.js:17773:24)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNode (tsserver.js:17533:24)
    at Object.forEachChild (tsserver.js:17663:21)
    at addChildrenRecursively (tsserver.js:112264:28)
    at visitNodes (tsserver.js:17542:30)
    at Object.forEachChild (tsserver.js:17782:24)
    at addChildrenRecursively (tsserver.js:112413:24)
    at visitNode (tsserver.js:17533:24)
    at Object.forEachChild (tsserver.js:17780:21)
    at addChildrenRecursively (tsserver.js:112413:24)
    at rootNavigationBarNode (tsserver.js:112117:17)
    at Object.getNavigationTree (tsserver.js:112083:38)
    at Object.getNavigationTree (tsserver.js:130754:37)
    at IOSession.Session.getNavigationTree (tsserver.js:140231:44)
    at Session.handlers.ts.createMapFromTemplate._a.(anonymous function) (tsserver.js:139125:61)
    at tsserver.js:140562:88
    at IOSession.Session.executeWithRequestId (tsserver.js:140553:28)
    at IOSession.Session.executeCommand (tsserver.js:140562:33)
    at IOSession.Session.onMessage (tsserver.js:140585:35)
    at Interface.<anonymous> (tsserver.js:141900:27)
    at Interface.emit (events.js:182:13)
    at Interface._onLine (readline.js:290:10)
    at Interface._normalWrite (readline.js:433:12)
    at Socket.ondata (readline.js:149:10)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
    at Function.create (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:53:63415)
    at h.dispatchResponse (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:53:56570)
    at h.dispatchMessage (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:53:55468)
    at constructor._reader.onData.e (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:53:54944)
    at l.fire (/Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:50:519)
    at t.Reader.onLengthData (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:53:61635)
    at Socket.t.Reader.constructor.e.on.e (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/typescript-language-features/dist/extension.js:53:61283)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137

Does this happen in a specific file? Also can you check to see if when the error happens is tied to when you first see the loading indicator?

Happened again, but this time I didn't see anything in the VSC developer console.

Literally did this:

  1. Opened a .JSX file, there was a component on it;
  2. Right-clicked the component, selected "Go to definition";
  3. The file with the definition (a .JS file with React code in it) opens up (non-editable, file name tab is in italics) - this file also has a React component on it, did not tried to follow its definition;
  4. Proceeded to edit the JSX file - did not save it;
  5. Switched back to the .JS file and on hovering the React component on it the "Loading..." tooltip keeps spinning without loading anything.

Console shows only this:

console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
_register._socket.onData.e @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94
console.ts:137 [Extension Host] TextEditor is closed/disposed
t.log @ console.ts:137
$logExtensionHostMessage @ mainThreadConsole.ts:39
_doInvokeHandler @ rpcProtocol.ts:398
_invokeHandler @ rpcProtocol.ts:383
_receiveRequest @ rpcProtocol.ts:299
_receiveOneMessage @ rpcProtocol.ts:226
_protocol.onMessage.e @ rpcProtocol.ts:101
fire @ event.ts:580
fire @ ipc.net.ts:453
_receiveMessage @ ipc.net.ts:733
_socketDisposables.push._socketReader.onMessage.e @ ipc.net.ts:592
fire @ event.ts:580
acceptChunk @ ipc.net.ts:239
_register._socket.onData.e @ ipc.net.ts:200
t @ ipc.net.ts:28
emit @ events.js:182
addChunk @ _stream_readable.js:283
readableAddChunk @ _stream_readable.js:264
Readable.push @ _stream_readable.js:219
onStreamRead @ internal/stream_base_commons.js:94

Is there any other way I can check logs besides the built-in Chromium Developer Tools?

To check the TS Server

  1. Set "typescript.tsserver.log": "verbose",
  2. Restart VS Code and reproduce the problem
  3. In VS Code, run the TypeScript: Open TS Server log command
  4. This should open a large log file called tsserver.log

Look through that log file for errors or stack traces. If you can share the log, I can also take a look to see if anything stands out

Here's the log.
ts.log

Thanks for the logs. Moved upstream to TS. The project updating in the logs looks suspicious but someone on the TS team should be able to confirm

As a work around, you can try creating a jsconfig file

It seems like there might be multiple issues:
1) The getReferencedSymbolsForModuleIfDeclaredBySourceFile exception looks the same as #30896, #33755, and #32858.
2) The unescapeLeadingUnderscores looks similar to a family of exceptions that have shown up in telemetry bugs since ~2.6.
3) The log shows some responsiveness issues during initialization, but I don't see anything related to either (1) or (2).

@MuTLY any chance you could grab a log for a session is which exceptions are written to the console?

@amcasey here's a full verbose log of a session where the issue occured.

-1571690885284.log

Sorry, I should have been clearer - do you have a _server_ log for that session?

If you still have typescript.tsserver.log enabled (from above), you should be able to just TypeScript: Open TS Server log.

Here we go.

ts-server-log.log

Weird - it still doesn't show the errors you're seeing in the console, even though the console errors are from the component doing the logging. I'll see if I can figure out why that might be happening. Thanks for your patience!

Oh wait, that's from a new session! Let me upload the dev tools log too.

@amcasey the above log is from the same session of the TS log up there.

@MuTLY I think I've pinned down exact steps. If you navigate to the Output panel and select "TypeScript" from the dropdown, it will show both exceptions and the paths to the corresponding log files. Next time you see an exception in the TypeScript Output, please grab the corresponding log(s). If you've had VS Code open for a while, there may already be occurrences in the TypeScript Output. Again, thanks for your patience - I'm used to collecting logs from VS, rather than VS Code.

Here's what I've found by looking at the output panel. I've zipped the whole log folder. Hope it helps.

vscode.typescript-language-features.zip

Still nothing. 馃槩 Investigating should still be possible without those logs - just harder. I'll see what I can figure out and let you know if I have questions.

This appears to be an easy repro for the unescapeLeadingUnderscores issues:

function F(key, value) {
    return {
        [key]: value,
        "prop": true
    }
}

The fix for (2) is merged and the fix for (1) is in PR. I think (3) is too broad to cover in the same GH issue, so I'm inclined to close this once the second PR merges. @MuTLY?

I'm good with that. Thank you @amcasey and @mjbvz so much for looking into this.

I'm not sure what time we snap for the nightly build, but the fixes should be reflected in typescript@next tomorrow or the next day.

Was this page helpful?
0 / 5 - 0 ratings