How do I see the logs of a VSCode Language Server process? - visual-studio-code

Situation
I'm experimenting with writing a VSCode Language Server Protocol (LSP) Extension. I've got it running as follows:
An lsp-server process which is launched by running haskell-lsp-example-exe from terminal
An lsp-client written in Typescript which, for now, basically just launches lsp-server (it's based on the lsp-sample repo)
The lsp-server is launch as follows:
# extension.ts
let serverOptions: ServerOptions = {
run: {
command: "haskell-lsp-example-exe"
},
}
The lsp-client is launched using code --extensionDevelopmentPath="path/to/extension"
I can see that it launches correctly, and I can find its pid through Activity Monitor (I'm on Mac).
Question
How can I see the logs of this process which is spawned by VSCode?
Context
I have tried the following:
In lsp-client/package.json I set the following which gives me the messages going back and forth. But not the logs of lsp-server.:
"languageServerExample.trace.server": {
"scope": "window",
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "verbose",
"description": "Traces the communication between VS Code and the language server."
}
I've also tried opening up dev tools in the launched instance of VSCode, but that gives the logs of lsp-client
The log labelled Log (Extension Host) in the launched instance of VSCode also doesn't look too useful
Thanks in advance for any help!

Related

Debug Remote Java Application using VS Code

In Eclipse, we have possibility to set debug configuration for remote Java application.
I have attached the same in image.
How can same be achieved in VS code using Community Server Connector extension?
To attach to a remote debugging session for a Java project
Open the project in VSCode and select the folder containing the source
Click on the Run menu then select Open Configurations or Add Configuration..., if you use the Add method, select Java: Attach to remote program and it will put the lines below in for you
Add the remote server details
{
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "[Name for debug session]",
"request": "attach",
"hostName": "[Remote Host Address]",
"port": [Debug Port],
}
]
}
Click on Run and select Start Debugging
Edit: This JSON is held in the [project root]/.vscode/launch.json file
Edit: If you have multiple configuration, then hit Ctrl + Shift + P and select Debug: Select and Start Debugging and select the configuration (the value you put in the Name field) that you want to use.

Debug Flutter web app in VS Code without creating a Microsoft Edge new instance

everything is set up and working but when I start debugging flutter in vs code using microsoft edge it starts a new instance , meaning the browser data, password, settings .... are all reset, so i need to enter passwords and change settings every time i start debugging or i need to open two browser instances which is both resources intensive and clingy.
is there like vs code configuration for flutter that works as "attach" to an existing browser instance instead of "launch" a new instance ?
you have to run with following command,
flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0
then access http://<your-ip> or localhost:8080
with this you can open your flutter web-app in regular browser and also you can open it in other devices in network(with your ip)
** also you should ensure that your port(8080) is open.
Normally, if Microsoft Edge is already running when you start debugging with a launch config, then the new instance won't start in remote debugging mode.
So by default, the extension launches Microsoft Edge with a separate user profile in a temp folder. Use userDataDir to set a different path to use, or set to false to launch with your default user profile.
A simple example:
{
"configurations": [
{
"name": "Launch Microsoft Edge",
"request": "launch",
"type": "edge",
"url": "...\\Index.html", // Provide your project's url to finish configuring
"userDataDir": false // You could also add ${local_app_data}\Edge\Profile, such as C:\Users\<Current-user>\AppData\Local\Microsoft\Edge\Profile
}
]
}
I don't have a perfect solution, as this one requires you to install the Dart Debug Extension, but you can create a launch.json and paste this command:
{
"version": "0.2.0",
"configurations": [
{
"name": "Flutter Web Project",
"type": "dart",
"request": "launch",
"program": "lib/main.dart",
"args": [
"-d",
"web-server"
]
}
]
}

VSCode failed to attach to process

I am using VSCode on Windows to debug a process on remote Linux host. I have added launch configuration that look like this:
{
"type": "gdb",
"request": "attach",
"name": "Attach to PID",
"target": "3441",
"cwd": "${workspaceRoot}"
},
But when I am trying to launch debugged I get this output in Debug console:
Attaching to process 3441
[New LWP 3442]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
__libc_do_syscall () at ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S:47
47 ../sysdeps/unix/sysv/linux/arm/libc-do-syscall.S: No such file or directory.
Not implemented stop reason (assuming exception): undefined
The last line looks suspicious as if the debugger was not able to stop the process for some reason. At the same time a message box with the following text is displayed:
Failed to attach: Cannot change this setting while the inferior is running. (from gdb-set target-async on)
I tried running gdb on the machine through ssh and attach to the process and it works ok.
So the question is: how do I get this running? I also tried enabling logging by adding this to launch.json:
"logging": {
"engineLogging": false
}
But vscode editor claims Property logging is not allowed and it doesn't seem to make any difference.
Any ideas?

Azure Service Fabric gets terminated in local cluster when running tests

So we are using Azure Service Fabric and gets a weird behavior when trying to run API tests against my local development cluster.
Every time I start the test the app gets terminated, sometimes it gets restarted again but most often it just stays terminated (and even deleted from the cluster).
I guess its somehow connected against that when I run the API test it will run and build stuff that the service fabric is using, but since the outcome is different depending on something (maybe the sun?) it feels like I am either missing something or experience a bug with service fabric.
Do anyone have any idea? Consider me as a noob and assume that I have done something wrong myself (I am doing that atleast).
UPDATE
There was a question on how we do run our tests:
Starts 2 instances of Visual Studio
Open the same .sln in both of them
Start the Service Fabric project.
Wait until cluster reports OK.
Run api test through a unit test (both service bus tests and REST tests) with Resharper test runner
Now we get the messages that is attached in diagnostics.
Diagnostics:
Event #1
{
"Timestamp": "2018-10-16T08:14:03.0590414+02:00",
"ProviderName": "Microsoft-ServiceFabric",
"Id": 23083,
"Message": ApplicationHostTerminated: ApplicationId=fabric:/<MyService>, ServiceName=fabric:/<MyService>, ServicePackageName=<MyPackage>, ServicePackageActivationId=8f36ac97-9271-4a49-94ce-dd296aebffa5, IsExclusive=True, CodePackageName=Code, EntryPointType=Exe, ExeName=MyExe, ProcessId=24568, HostId=d2a820b5-5b4d-42af-ae87-350028a3fa72, ExitCode=3221225786, UnexpectedTermination=False, StartTime=10/16/2018 08:12:14. ",
"ProcessId": 22660,
"Level": "Informational",
"Keywords": "0x4000000000000001",
"EventName": "Hosting",
"ActivityID": null,
"RelatedActivityID": null,
"Payload": {
"eventInstanceId": "\"07f15452-2f75-49e3-ad5d-d16ea49bdc8f\"",
"applicationName": "MyAppName",
"ServiceName": "fabric:/MyServiceName",
"ServicePackageName": "MyPackageName",
"ServicePackageActivationId": "8f36ac97-9271-4a49-94ce-dd296aebffa5",
"IsExclusive": true,
"CodePackageName": "Code",
"EntryPointType": 1,
"ExeName": "MyExe",
"ProcessId": 24568,
"HostId": "d2a820b5-5b4d-42af-ae87-350028a3fa72",
"ExitCode": 3221225786,
"UnexpectedTermination": false,
"StartTime": "\"\/Date(1539670334917)\/\""
}
}
Event #2
{
"Timestamp": "2018-10-16T08:14:02.3557708+02:00",
"ProviderName": "Microsoft-ServiceFabric",
"Id": 29625,
"Message": "Application deleted: Application = fabric:/MyApp, Application Type = MyServiceType ",
"ProcessId": 22660,
"Level": "Informational",
"Keywords": "0x4000000000000001",
"EventName": "CM",
"ActivityID": null,
"RelatedActivityID": null,
"Payload": {
"eventInstanceId": "\"ca608cec-8d55-4606-a331-8ebfcfff8fa6\"",
"applicationName": "fabric:/MyAppName",
"applicationTypeName": "MyAppTypeName",
"applicationTypeVersion": "1.0.0"
}
}
I think you can experience a side effect of Application Debug Mode set for your .sfproj.
By default Application Debug Mode is set to Refresh Application (which if you are using 5-node cluster is automatically changed to Remove Application) or Remove Application debug mode. This instructs Visual Studio to recreate the application for each debugging session and remove it when session ends.
Changing it to Keep Application should prevent the Visual Studio from recreating the application during debugging session.

Protractor test fails on CI

Currently I am trying a setup an end to end protractor tests to a a bitbucket pipelines with set up an headless chrome and i am currently getting some error message:
Failed: This driver instance does not have a valid session ID (did you call WebDriver.quit()?) and may no longer be used.
Any clue for this? how ever running tests locally is working fine; Can i set a constant session id?
Thanks
Check out your configuration file for this object
capabilities: {
"browserName": "chrome",
"chromeOptions": {
"args": ["incognito", "--window-size=1920,1080", "disable-extensions", "--no-sandbox", "start-maximized", "--test-type=browser"],
"prefs": {
"download": {
"prompt_for_download": false,
"directory_upgrade": true,
"default_directory": path.join(process.cwd(), "__test__reports/downloads")
}
}
}
},
When you find it, make sure you included "--no-sandbox" argument into args property.
What this guy does is it allows your tests to be ran from a remote container. In the meantime, if you include the argument when you run your tests on your machine, it has side effects like described here Chrome Instances don't close after running Test Case in Protractor