ECONNREFUSED error with WSL 2 with Chrome Debugger on VSCode - html

I'm on a Windows 10 machine, VS Code with WSL 2 (Ubuntu 18.04) trying to use the Chrome debugger extension, but to no avail. The following is my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch index.html",
"type": "chrome",
"request": "launch",
"file": "${workspaceFolder}/index.html",
"runtimeExecutable": "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
"runtimeArgs": [" --remote-debugging-port=9222"],
"userDataDir": "${workspaceFolder}/chrome",
"port": 9222
},
]
}
I was expecting to see my index.html page loaded in a new Chrome tab whenever I press F5, but all it does is start a new, blank Chrome window and then two errors pop up about 15 seconds apart.
I'm less concerned about the first error, which says Google Chrome cannot read and write to its data directory: <VALID-DIRECTORY-ON-MY-MACHINE>. What I have been trying to address for the past day and a half is the second error, which says
Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:9222)
I tried a lot of the solutions on Stack, GitHub, VS Code dev site etc. but nothing helps. On my Chrome browser, http://localhost:9222/json throws out some content which I understood to mean that the browser should be available for connection:
[ {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/E7E1DFE661F744BE79A572564251BC39",
"id": "E7E1DFE661F744BE79A572564251BC39",
"title": "New Tab",
"type": "page",
"url": "http://localhost:9222/json",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/E7E1DFE661F744BE79A572564251BC39"
}, {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/C089932CAB5A26F4409B78F887C84A50",
"id": "C089932CAB5A26F4409B78F887C84A50",
"title": "about:blank",
"type": "page",
"url": "about:blank",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/C089932CAB5A26F4409B78F887C84A50"
} ]
In addition, I've also set in my settings.json: "remote.extensionKind": {"msjsdiag.debugger-for-chrome": "workspace"} based on this recommendation. I've also restarted my machine, start VS Code and then launch (without opening any other Chrome windows).
It seems that all the things that were supposed to work doesn't, which meant that I could be misunderstanding something here. My question is, is there something that I'm doing incorrectly here?

It is a bug of vscode. This issue can be fixed by replacing extensions 'JavaScript Debugger' with 'JavaScript Debugger (Nightly)'.
See: https://github.com/microsoft/vscode/issues/120227

Related

Progressive web app works on local setup, but on staging, Chrome console reads "Manifest: Line: 1, column: 1, Syntax error"

I have two separate, but related, progressive web apps that each have a manifest.json file. One app is available at /foo/app and the other app at /bar/app on the same domain. The manifest.json file is available at /foo/app/manifest.json and /bar/app/manifest.json respectively.
On my local machine they work just fine (provided I start Chrome with a few special command-line flags to ignore self-signed certs). I can install both apps, and I can access from my Android phone via ngrok and install them there as well. However, after I uploaded everything to staging, I started seeing this console error in Chrome:
Manifest: Line: 1, column: 1, Syntax error.
I went over the file with a fine-toothed comb and couldn't find any issues. I read other Stack Overflow questions but came up dry. I found this W3 article about manifest.json and decided to change the name of the file from manifest.json to manifest.webmanifest and serve it with a MIME-type of application/manifest+json (as per w3 recommendations). None of this made any difference.
Why would there be a syntax error on staging when it works fine on local? The only difference is that my local setup uses a self-signed SSL/TLS certificate, so if anything, I'm surprised it works on local via ngrok!
Here is my manifest.webmanifest file:
{
"short_name": "Foo",
"name": "Foo",
"icons": [
{
"src": "/img/foo-logo-no-text-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/img/foo-logo-no-text-512x512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/foo/app/?source=pwa",
"background_color": "#54799C",
"display": "standalone",
"scope": "/foo/app/",
"theme_color": "#54799C"
}
Found the problem. This answer worked for me.
In short, I added crossorigin="use-credentials" to the <link rel="manifest"> element in my <head> section.

Debug Angular-CLI app accross Visual Studio Code not on localhost:4200

All!
How enable debug mode in Visual Studio Code for Angular-CLI application with arbitrary url.
With default ng serve url (localhost:4200) it works fine.
With another url breakpoints are set but not bound.
Here's vscode launch.config
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"sourceMaps": true,
"sourceMapPathOverrides": {
"webpack:///./*":"${workspaceRoot}/*"
},
"url": "http://localhost/CountrySite/v2/",
"webRoot": "${workspaceRoot}"
},
app folder structure
Thanks
The reason was in 401 response for js-sourcemaps returned from web server.
Solved

Visual studio code launches chrome with no extensions or autofill data [duplicate]

This question already has answers here:
run vscode chrome debugger with its extensions
(2 answers)
Closed 3 years ago.
I've recently started using chrome debugging for visual studio code on an angular project.
I've followed all the configuration steps described here and I'm able to successfully launch chrome against localhost, place breakpoints on VS Code and debug my code from there.
The issue is that the instance of chrome that VS Code launches does not have any of my chrome extensions, no auto fill information available and maybe even more things are missing.
Here is my launch.jsoncode:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}
How may I configure VS Code to launch a chrome instance with everything that I would usually have available on chrome?
After struggling for some time, I've found a way to make it work. I've modified my launch config to also set userDataDir field to false:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"userDataDir": false
}
]
}
This will open chrome with all extensions enabled and autofill data available. Still, this only works if there is no chrome instance currently running.

How to attach the VSCode debugger to the Brave browser?

When I open my web application in the Chrome browser I can attach the VSCode debugger to it.
The debugger configuration is:
{
"name": "Attach to Chrome",
"type": "chrome",
"request": "attach",
"port": 9222,
"url": "http://localhost:4200/*",
"webRoot": "${workspaceFolder}",
},
But when I open the web application in the Brave browser I cannot attach the VSCode debugger.
The web application is an Angular one opened at http://localhost:4200/users
I'm running:
Chrome Version 70.0.3538.102 (Build officiel) (64 bits)
Brave Version 0.56.12 Chromium: 70.0.3538.77 (Build officiel) (64 bits)
VSCode Version 1.23.0
on a Lubuntu 16.04 box.
Is the Brave browser not yet ready for debugging ? Or is there some port restriction I should remove ? I have put the shiled down for this web application. But VSCode still does not attach to it.
For MacOS users
I was able to connect to create a configuration in launch.json so that the Brave browser launches on MacOS. I appended the "userData": true property because I was getting an error. I figured that out by looking at this page. https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome
{
"type": "chrome",
"request": "launch",
"name": "Brave",
"runtimeExecutable": "/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
"userDataDir": true,
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
A little late but....
get brave-dev following this
then add to your launch.json a "runtimeExecutable": "/usr/bin/brave" entry and change the path that suits you.
rest of the settings can be default
The DEV version of Brave is not necessary.
In your Brave browser, under "chrome://settings/privacy", enable the "Remote debugging" option.
Restart your browser.
If not done yet, add to your launch.json file this (adjust your path if it is not the same)
"runtimeExecutable": "C:\\Program Files (x86)\\BraveSoftware\\Brave-Browser\\Application\\brave.exe",
As mentioned in the other answers, you need to add a "runtimeExecutable" field in the launch.json file of your project that will point to the executable of Brave Browser.
... but ...
You also need to launch the browser with the following option : --remote-debugging-port=9222
You have 2 ways to do it :
Launching Brave with the option (Windows : Right click the Brave shortcut, and select properties, and in the "target" field, append --remote-debugging-port=9222, MacOS / linux : execute <path to brave>/brave --remote-debugging-port=9222) (reminder : don't forget to relaunch Brave)
Following Cornelius suggestion, you can simply add the following to your launch.json :
"runtimeArgs": [ "--remote-debugging-port=9222" ]
This second option applies ONLY if you have the request: "launch" option, not the request: "attach" one, and if you want to use the "lauch" option, it will open another Brave window, not a new tab. So you'll probably want to use the first method in the long run.
For those that need to see full code context, here is my complete launch.json file. The second item in the "configurations" array causes brave's dev browser to open for debugging (you can download the Brave dev browser here)
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
},
{
"type": "chrome",
"request": "launch",
"name": "Brave",
"runtimeExecutable": "C:/Program Files (x86)/BraveSoftware/Brave-Browser-Dev/Application/brave.exe",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}
Brave install with APT package manager on Running Ubuntu 20.04
Add this line to the standard launch.json generated for chrome:
"runtimeExecutable": "/usr/bin/brave-browser"
Here is how the whole launch.json looks. If you want to copy this just make sure file points to the right location.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Open index.html",
"file": "/home/my-user/myDirectory/index.html",
"runtimeExecutable": "/usr/bin/brave-browser"
}
]
}
Steps to follow:
Open vs code.
wait for sec. bez it take time to open vs code
see left side Search icon.
click on it and type Setting.
see down click on Open setting.
Browser.
"liveServer.settings.AdvanceCustomBrowserCmdLine": "brave
or try this:
.vscode\settings.json:
{
"liveServer.settings.AdvanceCustomBrowserCmdLine": "brave"
}

Azure custom script extension never finishes deploying

I have a simple template that deploys a NIC, a VM, and a CustomScriptExtension:
{
"name": "Microsoft.CustomScriptExtension-20161202",
"apiVersion": "2015-01-01",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "incremental",
"templateLink": {
"uri": "https://gallery.azure.com/artifact/20161101/Microsoft.CustomScriptExtension-arm.2.0.50/Artifacts/MainTemplate.json"
},
"parameters": {
"vmName": {
"value": "[parameters('virtualMachineName')]"
},
"location": {
"value": "[parameters('configScriptLocation')]"
},
"fileUris": {
"value": "[parameters('configScriptFileUris')]"
}
}
},
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]"
]
},
My script enables some windows features, downloads .NET 4.6.1 from blob storage and installs it. I've been running this template over and over deleting the VM, NIC, and VHD in between each deploy. Yesterday, I began to encounter an issue where my script extension never finishes deploying.
I'll let the powershell script which calls New-AzureRmResourceGroupDeployment run and run but it never returns.
Here's what I know:
The portal shows that the script extension's status is deploying and duration is 1s.
When I sign into the VM, no log file has been created which indicates to me that the script has not even started since its first line creates the log file.
There is an empty folder at C:\Packages\Plugins\Microsoft.Compute.CustomScriptExtension\1.8
Under Event Viewer -> Applications and Services Logs -> Microsoft -> WindowsAzure -> Status -> Plugins I see that it is trying to download Microsoft.Compute_CustomScriptExtension_useast2_manifest.xml but can't resolve the hostname. In fact, all name resolution appears to be broken. I suspect this is the true problem but will continue investigation.
Why does my script extension never finish deploying? I tried clicking the Deployments link on the header of my resource group and, from there, deleting the deployments in case those deployment histories were somehow interfering but it appears not to help.
I've also noticed that my extension appears in the portal with the name 'CustomScriptExtension' while I would expect it to be 'Microsoft.CustomScriptExtension-20161202'.
We changed the DNS server and now my extensions are provisioning successfully.