microsoft/vscode-mssql

mssql: SQL Tools Service component could not start.

edvaldig opened this issue · 5 comments

  • MSSQL Extension Version: 1.0
  • VSCode Version: 1.13.1
  • OS Version: Windows 10 Enterprise

Steps to Reproduce:

  1. Install mssql extension in vscode
  2. Reload

SQLToolsService initialization output will say

Initializing SQL tools service for the mssql extension.
Note: mssql commands will be available after installing the service.

Platform: win32, x86_64 (Windows)

Installing SQL tools service to C:\Users\username\.vscode\extensions\ms-mssql.mssql-1.0.0\sqltoolsservice\1.0.0\Windows.
Downloading https://download.microsoft.com/download/3/A/E/3AE0DD0F-86A1-46CD-BFE2-E106E7CC8508/microsoft.sqltools.servicelayer-win-x64-netcoreapp1.0.zip
(26779 KB) .................... Done!
Installing ...
Done! 372 files unpacked.

SQLToolsService output:

Unhandled Exception: System.AggregateException: One or more errors occurred. (One or more errors occurred. (The given path's format is not supported.)) ---> System.AggregateException: One or more errors occurred. (The given path's format is not supported.) ---> System.NotSupportedException: The given path's format is not supported.
at System.IO.Path.GetFullPath(String path)
at Microsoft.SqlTools.ServiceLayer.Workspace.Workspace.ResolveFilePath(String filePath)
at Microsoft.SqlTools.ServiceLayer.Workspace.Workspace.GetFileBuffer(String filePath, String initialBuffer)
at Microsoft.SqlTools.ServiceLayer.Workspace.WorkspaceService1.<HandleDidOpenTextDocumentNotification>d__38.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SqlTools.Hosting.Protocol.MessageDispatcher.<DispatchMessage>d__33.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SqlTools.Hosting.Protocol.MessageDispatcher.<ListenForMessages>d__32.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.SqlTools.Utility.AsyncContext.Start(Func1 asyncMainFunc)
at System.Threading.Tasks.Task.Execute()
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at Microsoft.SqlTools.Hosting.Protocol.ProtocolEndpoint.WaitForExit()
at Microsoft.SqlTools.ServiceLayer.Program.Main(String[] args)
[Error - 3:05:37 PM] Connection to server got closed. Server will not be restarted.

After restarting mssql, the SQLToolsService output will repeat. and a popup error dialog that says "mssql: SQL Tools Service component could not start."

@edvaldig thanks for raising this. I can work on fixing this, I think there's a sensible solution here. However it would also be very beneficial to help diagnose the root cause. To help with this, could you please help me understand:

  • The path to your workspace / what opened files you have (particularly any .sql files)
  • Do you use source control, and if so what type?
    As this is crashing due to file path issues this would help us understand any gaps that may cause problems in other areas / for other people.

Regards,
Kevin

Sure thing,

The path to your workspace / what opened files you have (particularly any .sql files)
The path is a standard ascii no special characters or spaces so it can't be that, which leads me to the next part:

Do you use source control, and if so what type?
yes, perforce! I had installed an extension for it that I didn't follow up on after getting errors with it. After disabling it, then the mssql extension installed and loaded correctly! If you want I can try to dig up what the issues were with the perforce extension so that you can detect this dependency issue and fix the handling of it.

Great - so that's the core issue. VSCode introduced a breaking change a while back, where it sends file opened messages for source control over the same channel as regular files. This means we either need to filter messages by provider type (e.g. we filter git: as a provider), or handle in a robust way that handles arbitrary "not really a file path" paths sent over the channel. As you can tell, we don't currently filter by perforce provider ID.

I think we need a more robust method here anyhow. The core issue is we try to open files on disk if they're not in the workspace. We should only do this if we know it's a good, resolved filepath. So I will work to do the right thing and get a real fix out. This should get into the next release given this is a bad regression.

I have PR out for this - see microsoft/sqltoolsservice#400. Much of the handling had already been fixed in a recent PR but I found a number of edge cases and especially our handling of null references was still problematic. This should resolve the issue. We're tracking mid-July for our next release, and we'll have daily builds with the fix sooner if you want to test using this.

Thanks!