You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugpapercut 🩸A particularly annoying issue impacting someone on the teamtypescriptTypescript support issuesverifiedVerification succeededwebIssues related to running VSCode in the web
I very often have to manually import a type because suggest was not fast enough to do the auto import. I feel this happens more for me in web than in desktop:
I am always picking the suggestion fast enough that I end up just with the word but not the auto import.
Slightly related: I often see something similar when I invoke quick fix on a missing type. At first I get no help and then trying again I get the advice to add the import.
Johannes Rieken (@jrieken) The root cause of this issue is that resolveCompletionItem may not complete before VS Code applies the completion. We've discussed this in the past but here are some of the issues I ran into while working around this item:
It is difficult to tell whether VS Code has applied the full completion item or not.
If VS Code has fully resolved the completion, the provider does not need to do anything. However there are cases like the one Ben was hitting where VS Code applies a completion before it has been fully resolved. In those cases, need to do extra work to manually apply the rest of the completion once it resolves.
However I cannot simply to see if resolveCompletionItem has been called since VS Code may accept the completion and apply it before resolveCompletionItem returns. You also cannot check at the end of resolveCompletionItem, because VS Code may apply the completion before the results get back to the main thread.
resolveCompletionItem is canceled in cases where the suggestion is accepted but resolve has not completed.
This makes sense, but it meant that I had to use my own cancellation token when making the request to TypeScript. I need to do because the following can happen:
start resolveCompletionItem()
resolveCompletionItem awaits TS server
The completion is accepted and resolveCompletionItem is canceled (along with the call to TS Server)
But to make sure we properly apply the completion, I have custom TS completion items that apply additional edits for auto imports in a command. This command needs the results of the call to the TypeScript server from resolveCompletionItem to apply auto import.
My workaround was to implement a custom cancellation token source that counts the number of callers who may need the response from TS server (it also uses a short timeout before actually cancelling the request).
I think my solution works, but it's quite ugly. Ideally TypeScript could eagerly returns all of the information we need to implement auto-imports, although they had concerns about how long that would take to compute and send over
The completion is accepted and resolveCompletionItem is canceled (along with the call to TS Server)
This is arguably a bug. We shouldn't do that when we have explicitly called resolve during insert.
It is difficult to tell whether VS Code has applied the full completion item or not.
I am not quite sure why you need to know that. There should be an editor guarantee that resolve is only called once and the provider should resolve the item independent of the editor state. Tho, that's the ideal view but IDK how the reality of a provider is. What am I missing?
Benjamin Pasero (@bpasero) Looks like you are using the add missing import quick fix after typing out toDisposable. If you accept the suggestion instead, do you see auto imports working?
Ok, I've extracted the quick fix issue to #117812.
Let's track auto imports suggestions in this issue. I believe auto import suggestion should be much more reliable now so please let me know if there are cases where you still see this
For Typescript I have similar issue, which happens completely random. Restarting VSC fixes behavior. Somehow it fixes itself
If the issue occurs it cannot go away.
Moreover, the import path is detected, but still it doesn't work.
This is somehow related to the place in code, where I want to auto-import, as seen in gif below (no import works for some reason)
I've scanned through logs and found this in Log (Remote Extension Host), and it occured almost at the same moment I tried to auto-import. Log was anonymized
[2021-04-12 13:14:41.808] [exthost] [error] [vscode.typescript-language-features] provider FAILED
[2021-04-12 13:14:41.808] [exthost] [error] Error: <semantic> TypeScript Server Error (3.9.2)
Debug Failure. False expression.
Error: Debug Failure. False expression.
at Object.first (path-to-project/node_modules/typescript/lib/tsserver.js:1023:18)
at Object.getImportCompletionAction (path-to-project/node_modules/typescript/lib/tsserver.js:129669:38)
at getCompletionEntryCodeActionsAndSourceDisplay (path-to-project/node_modules/typescript/lib/tsserver.js:112507:33)
at Object.getCompletionEntryDetails (path-to-project/node_modules/typescript/lib/tsserver.js:112471:30)
at Proxy.getCompletionEntryDetails (path-to-project/node_modules/typescript/lib/tsserver.js:138863:35)
at Proxy.<anonymous> (path-to-users-home/.vscode-server/extensions/jpoissonnier.vscode-styled-components-1.5.0/node_modules/typescript-template-language-service-decorator/lib/template-language-service-decorator.js:96:24)
at path-to-project/node_modules/typescript/lib/tsserver.js:148965:57
at Object.mapDefined (path-to-project/node_modules/typescript/lib/tsserver.js:562:30)
at IOSession.Session.getCompletionEntryDetails (path-to-project/node_modules/typescript/lib/tsserver.js:148963:33)
at Session.handlers.ts.createMapFromTemplate._a.<computed> (path-to-project/node_modules/typescript/lib/tsserver.js:147881:61)
at path-to-project/node_modules/typescript/lib/tsserver.js:149512:88
at IOSession.Session.executeWithRequestId (path-to-project/node_modules/typescript/lib/tsserver.js:149503:28)
at IOSession.Session.executeCommand (path-to-project/node_modules/typescript/lib/tsserver.js:149512:33)
at IOSession.Session.onMessage (path-to-project/node_modules/typescript/lib/tsserver.js:149536:35)
at Interface.<anonymous> (path-to-project/node_modules/typescript/lib/tsserver.js:150852:27)
at Interface.emit (events.js:315:20)
at Interface._onLine (readline.js:329:10)
at Interface._normalWrite (readline.js:474:12)
at Socket.ondata (readline.js:186:10)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
at Function.create (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:70073)
at dispatchResponse (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:63948)
at dispatchMessage (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:62807)
at path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:62317
at b.fire (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/out/vs/server/remoteExtensionHostProcess.js:57:1836)
at g.onLengthData (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:431280)
at Socket.<anonymous> (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:430928)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
[2021-04-12 13:14:42.130] [exthost] [error] Error: <semantic> TypeScript Server Error (3.9.2)
Debug Failure. False expression.
Error: Debug Failure. False expression.
at Object.first (path-to-project/node_modules/typescript/lib/tsserver.js:1023:18)
at Object.getImportCompletionAction (path-to-project/node_modules/typescript/lib/tsserver.js:129669:38)
at getCompletionEntryCodeActionsAndSourceDisplay (path-to-project/node_modules/typescript/lib/tsserver.js:112507:33)
at Object.getCompletionEntryDetails (path-to-project/node_modules/typescript/lib/tsserver.js:112471:30)
at Proxy.getCompletionEntryDetails (path-to-project/node_modules/typescript/lib/tsserver.js:138863:35)
at Proxy.<anonymous> (path-to-users-home/.vscode-server/extensions/jpoissonnier.vscode-styled-components-1.5.0/node_modules/typescript-template-language-service-decorator/lib/template-language-service-decorator.js:96:24)
at path-to-project/node_modules/typescript/lib/tsserver.js:148965:57
at Object.mapDefined (path-to-project/node_modules/typescript/lib/tsserver.js:562:30)
at IOSession.Session.getCompletionEntryDetails (path-to-project/node_modules/typescript/lib/tsserver.js:148963:33)
at Session.handlers.ts.createMapFromTemplate._a.<computed> (path-to-project/node_modules/typescript/lib/tsserver.js:147881:61)
at path-to-project/node_modules/typescript/lib/tsserver.js:149512:88
at IOSession.Session.executeWithRequestId (path-to-project/node_modules/typescript/lib/tsserver.js:149503:28)
at IOSession.Session.executeCommand (path-to-project/node_modules/typescript/lib/tsserver.js:149512:33)
at IOSession.Session.onMessage (path-to-project/node_modules/typescript/lib/tsserver.js:149536:35)
at Interface.<anonymous> (path-to-project/node_modules/typescript/lib/tsserver.js:150852:27)
at Interface.emit (events.js:315:20)
at Interface._onLine (readline.js:329:10)
at Interface._normalWrite (readline.js:474:12)
at Socket.ondata (readline.js:186:10)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23)
at Function.create (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:70073)
at dispatchResponse (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:63948)
at dispatchMessage (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:62807)
at path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:62317
at b.fire (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/out/vs/server/remoteExtensionHostProcess.js:57:1836)
at g.onLengthData (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:431280)
at Socket.<anonymous> (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/extensions/typescript-language-features/dist/extension.js:1:430928)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:295:12)
at readableAddChunk (_stream_readable.js:271:9)
at Socket.Readable.push (_stream_readable.js:212:10)
at Pipe.onStreamRead (internal/stream_base_commons.js:186:23) _typescript.applyCompletionCommand
[2021-04-12 13:14:42.130] [exthost] [error] Error: Running the contributed command: '_typescript.applyCompletionCommand' failed.
at S._executeContributedCommand (path-to-users-home/.vscode-server/bin/08a217c4d27a02a5bcde898fd7981bda5b49391b/out/vs/server/remoteExtensionHostProcess.js:86:106930)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5) _typescript.applyCompletionCommand
I noticed something important: for whatever reason in path-to-project I had path to another project in workspace. I worked in projectA, and tried to import there, yet got this errors with path to projectB
author-verification-requestedIssues potentially verifiable by issue authorbugIssue identified by VS Code Team member as probable bugpapercut 🩸A particularly annoying issue impacting someone on the teamtypescriptTypescript support issuesverifiedVerification succeededwebIssues related to running VSCode in the web
Activity
bpasero commentedon Oct 27, 2020
Slightly related: I often see something similar when I invoke quick fix on a missing type. At first I get no help and then trying again I get the advice to add the import.
mjbvz commentedon Feb 2, 2021
Johannes Rieken (@jrieken) The root cause of this issue is that
resolveCompletionItemmay not complete before VS Code applies the completion. We've discussed this in the past but here are some of the issues I ran into while working around this item:It is difficult to tell whether VS Code has applied the full completion item or not.
If VS Code has fully resolved the completion, the provider does not need to do anything. However there are cases like the one Ben was hitting where VS Code applies a completion before it has been fully resolved. In those cases, need to do extra work to manually apply the rest of the completion once it resolves.
However I cannot simply to see if
resolveCompletionItemhas been called since VS Code may accept the completion and apply it beforeresolveCompletionItemreturns. You also cannot check at the end ofresolveCompletionItem, because VS Code may apply the completion before the results get back to the main thread.resolveCompletionItemis canceled in cases where the suggestion is accepted but resolve has not completed.This makes sense, but it meant that I had to use my own cancellation token when making the request to TypeScript. I need to do because the following can happen:
resolveCompletionItem()resolveCompletionItemawaits TS serverresolveCompletionItemis canceled (along with the call to TS Server)resolveCompletionItemto apply auto import.My workaround was to implement a custom cancellation token source that counts the number of callers who may need the response from TS server (it also uses a short timeout before actually cancelling the request).
I think my solution works, but it's quite ugly. Ideally TypeScript could eagerly returns all of the information we need to implement auto-imports, although they had concerns about how long that would take to compute and send over
jrieken commentedon Feb 2, 2021
This is arguably a bug. We shouldn't do that when we have explicitly called resolve during insert.
I am not quite sure why you need to know that. There should be an editor guarantee that resolve is only called once and the provider should resolve the item independent of the editor state. Tho, that's the ideal view but IDK how the reality of a provider is. What am I missing?
Make sure we always apply TS auto imports, even if VS Code applies th…
5 remaining items
mjbvz commentedon Feb 26, 2021
Benjamin Pasero (@bpasero) Looks like you are using the add missing import quick fix after typing out
toDisposable. If you accept the suggestion instead, do you see auto imports working?mjbvz commentedon Feb 26, 2021
I'd prefer splitting any problem with quick fixes to their own issue as they are a separate feature
bpasero commentedon Feb 26, 2021
Yes I press
Cmd+.and need to do that multiple times until I get a suggestion. I would rather delay it until we can show a fix.mjbvz commentedon Feb 27, 2021
Ok, I've extracted the quick fix issue to #117812.
Let's track auto imports suggestions in this issue. I believe auto import suggestion should be much more reliable now so please let me know if there are cases where you still see this
olegKusov commentedon Mar 9, 2021
I'm having same issue . Big Sur. Vs code Version: 1.54.1. I can wait 5 minutes and it doesnt work.
2021-03-09.17.00.24.mov
mjbvz commentedon Mar 9, 2021
Oleg Kusov (@olegKusov) Please open a separate issue with an example project that demonstrates the problem
soanvig commentedon Apr 12, 2021
For Typescript I have similar issue, which happens completely random. Restarting VSC fixes behavior. Somehow it fixes itself
I've scanned through logs and found this in
Log (Remote Extension Host), and it occured almost at the same moment I tried to auto-import. Log was anonymizedI noticed something important: for whatever reason in
path-to-projectI had path to another project in workspace. I worked inprojectA, and tried to import there, yet got this errors with path toprojectBmjbvz commentedon Apr 12, 2021
Mateusz Koteja (@soanvig) Please don't post on generic, already resolved issues
You are using an old TS version so first check if you see this using TS 4.2+. If you do, open a new issue with a project that demonstrates the problem