TypeScript Server Error (4.5.4): Cannot read property 'close' of undefined
See original GitHub issueBug Report
🔎 Search Terms
TS Server Error, TypeScript Server Error, Cannot read property ‘close’ of undefined
🕗 Version & Regression Information
This is an issue I encounter on TypeScript 4.5.4, typescript@next
and TypeScript 4.5.3. I only tried these three.
🙁 Actual behavior
Code is irrelevant. When typing, I’m assuming when the server looks for symbols, suddenly the Intellisense stops. When I check the VSC console, I get the following logs:
Details
ERR <semantic> TypeScript Server Error (4.5.4)
Cannot read property 'close' of undefined
TypeError: Cannot read property 'close' of undefined
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:7578:33)
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:112778:29)
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:168181:37)
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:168197:33)
at d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:169618:186
at Map.forEach (<anonymous>)
at Object.clear (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:169618:142)
at ConfiguredProject.Project.updateGraphWorker (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:165117:47)
at ConfiguredProject.Project.updateGraph (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:164962:42)
at ConfiguredProject.updateGraph (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:165955:63)
at Object.updateProjectIfDirty (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:166444:45)
at ConfiguredProject.Project.getLanguageService (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:164576:28)
at IOSession.Session.getSignatureHelpItems (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:171629:41)
at Session.handlers.ts.Map.ts.getEntries._a.<computed> (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:170410:61)
at d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172193:88
at IOSession.Session.executeWithRequestId (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172184:28)
at IOSession.Session.executeCommand (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172193:33)
at IOSession.Session.onMessage (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172219:35)
at Interface.<anonymous> (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:174824:31)
at Interface.emit (events.js:315:20)
at Interface._onLine (readline.js:337:10)
at Interface._normalWrite (readline.js:482:12)
at Socket.ondata (readline.js:194:10)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23): Error: <semantic> TypeScript Server Error (4.5.4)
Cannot read property 'close' of undefined
TypeError: Cannot read property 'close' of undefined
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:7578:33)
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:112778:29)
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:168181:37)
at Object.close (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:168197:33)
at d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:169618:186
at Map.forEach (<anonymous>)
at Object.clear (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:169618:142)
at ConfiguredProject.Project.updateGraphWorker (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:165117:47)
at ConfiguredProject.Project.updateGraph (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:164962:42)
at ConfiguredProject.updateGraph (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:165955:63)
at Object.updateProjectIfDirty (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:166444:45)
at ConfiguredProject.Project.getLanguageService (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:164576:28)
at IOSession.Session.getSignatureHelpItems (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:171629:41)
at Session.handlers.ts.Map.ts.getEntries._a.<computed> (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:170410:61)
at d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172193:88
at IOSession.Session.executeWithRequestId (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172184:28)
at IOSession.Session.executeCommand (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172193:33)
at IOSession.Session.onMessage (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:172219:35)
at Interface.<anonymous> (d:\Programmes\Code\resources\app\extensions\node_modules\typescript\lib\tsserver.js:174824:31)
at Interface.emit (events.js:315:20)
at Interface._onLine (readline.js:337:10)
at Interface._normalWrite (readline.js:482:12)
at Socket.ondata (readline.js:194:10)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
at Function.create (d:\Programmes\Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:494353)
at dispatchResponse (d:\Programmes\Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:488189)
at dispatchMessage (d:\Programmes\Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:487046)
at d:\Programmes\Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:486531
at u.fire (d:\Programmes\Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:66:1712)
at m.onLengthData (d:\Programmes\Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:497282)
at Socket.<anonymous> (d:\Programmes\Code\resources\app\extensions\typescript-language-features\dist\extension.js:1:496929)
at Socket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at Socket.Readable.push (internal/streams/readable.js:223:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)
Restarting the TypeScript server works for a few seconds, and it stops again after a few seconds of typings. For instance, I created a new file where I started to type import
, and it crashed. A second time it didn’t crash, but then it crashed when I typed the symbol I imported.
🙂 Expected behavior
It shouldn’t crash when typing.
Reproduction
I’m really not sure how to reproduce this. My only TypeScript project for the moment is https://github.com/preset/preset, and this is the one TypeScript crashes in.
Maybe relevant: I’m using a pnpm
monorepository. TypeScript is installed at the root and in every package. I’ve tried VSC’s TypeScript version and the package’s version.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
The reason I tried signature help was the call to
IOSession.Session.getSignatureHelpItems
in the stack. The next things to happen were getLanguageService/updateProjectIfDirty, so maybe it behaves differently if you build the project first. I’ll trypnpm run build
and then check signature help again.So, I’ve been working on the project again. It took about 15 minutes for me to notice the TypeScript server crashed.
I restarted and tried again: I was working on the config, so
packages/core/src/config.ts
. I replaced all the code except the imports. I started adding a new function, trying to import the symbol of a package that I just added. It isn’t detected so I add the import, then I save. Before I save, I have this in the file:And when I saved I saw the TS server crash (I had devtools open).
If it’s of any help, here is my extension list:
Details
Tell me if I can give you any more useful information