vscode Fail to Debug Express Webapp - express
I'm trying to debug express (node) app on my machine, but debug does not start with no indication what so ever.
This happens on code I'm able to debug on another machine as well as "new" apps created in order to test this issue.
I followed the instructions on vscode site (https://code.visualstudio.com/docs/nodejs/nodejs-debugging) with no success.
Runtime works great - just fail to debug.
Behavior consist on all machine's users (admin/non-admin)
Does anyone have a clue?
My environment setup is:
operating System: Windows 10 Pro version 1803
node version: v10.13.0
vscode version: 1.28.2
This is vscode's trace (note the target not opened warning):
OS: win32 x64
Adapter node: v8.9.3 x64
vscode-chrome-debug-core: 6.7.19
11:20:18 AM, 11/7/2018
node-debug2: 1.28.3
From client: initialize({"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"node2","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us"})
To client: {"seq":0,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"exceptionBreakpointFilters":[{"label":"All Exceptions","filter":"all","default":false},{"label":"Uncaught Exceptions","filter":"uncaught","default":false}],"supportsConfigurationDoneRequest":true,"supportsSetVariable":true,"supportsConditionalBreakpoints":true,"supportsCompletionsRequest":true,"supportsHitConditionalBreakpoints":true,"supportsRestartFrame":true,"supportsExceptionInfoRequest":true,"supportsDelayedStackTraceLoading":true,"supportsValueFormattingOptions":true,"supportsEvaluateForHovers":true,"supportsLoadedSourcesRequest":true,"supportsLogPoints":true,"supportsTerminateRequest":false}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"ClientRequest/initialize","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3","successful":"true","timeTakenInMilliseconds":"3.774888","requestType":"request"}}}
From client: attach({"type":"node2","request":"attach","name":"Attach by Process ID","trace":true,"cwd":"c:\\Users\\roi\\dev\\janus\\src\\tools\\magento2-importer","port":9229,"protocol":"inspector","logFilePath":"c:\\Users\\roi\\AppData\\Roaming\\Code\\logs\\20181107T103352\\exthost1\\ms-vscode.node-debug\\debugadapter.txt","__sessionId":"910bc34a-3629-46b7-8c57-e89c06f5bda0"})
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"debugStarted","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3","request":"attach","args":["type","request","name","trace","cwd","port","protocol","logFilePath","__sessionId","enableSourceMapCaching","sourceMapPathOverrides","showAsyncStacks","sourceMaps"]}}}
Getting browser and debug protocol version via http://127.0.0.1:9229/json/version
Discovering targets via http://127.0.0.1:9229/json/list
Got browser version: node.js/v10.13.0
Got debug protocol version: 1.1
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"targetDebugProtocolVersion","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3"}}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"targetCount","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3","numTargets":1}}}
Attaching to target: {"description":"node.js instance","devtoolsFrontendUrl":"chrome-devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=localhost/a575db9e-d5a5-46a5-a49c-a553228c7493","devtoolsFrontendUrlCompat":"chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=localhost/a575db9e-d5a5-46a5-a49c-a553228c7493","faviconUrl":"https://nodejs.org/static/favicon.ico","id":"a575db9e-d5a5-46a5-a49c-a553228c7493","title":"dist/server.js","type":"node","url":"file://C:_Users_roi_dev_janus_src_tools_magento2-importer_dist_server.js","webSocketDebuggerUrl":"ws://127.0.0.1:9229/a575db9e-d5a5-46a5-a49c-a553228c7493","version":{}}
WebSocket Url: ws://127.0.0.1:9229/a575db9e-d5a5-46a5-a49c-a553228c7493
→ To target: "{\"id\":1,\"method\":\"Console.enable\"}"
→ To target: "{\"id\":2,\"method\":\"Debugger.enable\"}"
→ To target: "{\"id\":3,\"method\":\"Runtime.enable\"}"
→ To target: "{\"id\":4,\"method\":\"Log.enable\"}"
→ To target: "{\"id\":5,\"method\":\"Runtime.runIfWaitingForDebugger\"}"
→ Warning: Target not open! Message: "{\"id\":6,\"method\":\"Runtime.run\"}"
Websocket closed
Terminated: websocket closed
Waiting for any pending steps or log messages.
Current step and log messages complete
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"debugStopped","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3","reason":"websocket closed"}}}
To client: {"seq":0,"type":"event","event":"terminated"}
From client: disconnect({"restart":false})
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"FullSessionStatistics/SourceMaps/Overrides","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3","aspNetClientAppFallbackCount":0}}}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"report-start-up-timings","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3","RequestedContentWasDetected":"false","Steps":"[\"BeforeFirstStep\",\"ClientRequest/initialize\",\"ClientRequest/attach\",\"Attach\",\"Attach.RequestDebuggerTargetsInformation\",\"Attach.ProcessDebuggerTargetsInformation\",\"Attach.AttachToTargetDebuggerWebsocket\",\"Attach.ConfigureDebuggingSession.Internal\",\"Attach.ConfigureDebuggingSession.Target\"]","All":"380.614371","BeforeFirstStep":"[18.487202]","WaitingAfter.ClientRequest/initialize":"[22.151169]","ClientRequest/initialize":"[4.841868]","ClientRequest/attach":"[4.11239]","Attach":"[8.248859]","Attach.RequestDebuggerTargetsInformation":"[12.433092]","Attach.ProcessDebuggerTargetsInformation":"[0.720004]","Attach.AttachToTargetDebuggerWebsocket":"[317.133643]","Attach.ConfigureDebuggingSession.Internal":"[0.81632]","Attach.ConfigureDebuggingSession.Target":"[13.309018]","RequestedContentWasNotDetectedReason":"shutdown"}}}
Terminated: Got disconnect request
To client: {"seq":0,"type":"response","request_seq":3,"command":"disconnect","success":true}
To client: {"seq":0,"type":"event","event":"output","body":{"category":"telemetry","output":"ClientRequest/disconnect","data":{"Versions.DebugAdapterCore":"6.7.19","Versions.DebugAdapter":"1.28.3","successful":"true","timeTakenInMilliseconds":"2.443434","requestType":"request"}}}
This is snippet of vscode screen after debuger was attached. as you can see debugger was attached, but no debug tool bar is present (and no breaks on breakpoints):
You can try to add launch.json by go to Debug->Add Configuration
And then choose Node.js Attach To Process
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
},
{
"name": "Attach",
"type": "node",
"request": "attach",
"port": Your Port,
"address": "localhost",
"restart": false,
"sourceMaps": false,
"outDir": null,
"localRoot": "${workspaceRoot}",
"remoteRoot": null
}
]
}
Then run you server as usual, for example
> nodemon app.js
Set breakpoints
And hit Start Debugging
The debugger should kick in and you should smile :)
Related
How to configure VScode to debug a gradle/kotlin project?
Currently trying to consolidate development workflow for back and front in VScode with devcontainer, instead of InteliJ for back and VScode for front, with the use of Codespace/Gitpod in mind and a goal to ease the debug of the whole stack. I've read multiple tutorials for gradle in VScode and ended to something working to build and run, but the debugger don't work and I don't find any tutorials taking care of that part. The best result so far is with the following task and the Gradle extension for VScode: { "type": "gradle", "id": "/workspaces/mycode/serverrunMyCode", "script": "run", "description": "Runs this project as a JVM application", "group": "application", "project": "MyCode", "buildFile": "/workspaces/mycode/server/build.gradle.kts", "rootProject": "MyCode", "projectFolder": "/workspaces/mycode/server", "workspaceFolder": "/workspaces/mycode/server", "args": "", "javaDebug": true, "problemMatcher": [ "$gradle" ], "label": "Server Debug" } The server correctly build and run via VScode but the debugger does not work. I've tried with the Kotlin extensions and the following launch settings but here I get a missing dependencies issue "configurations": [ { "type": "kotlin", "request": "launch", "name": "Kotlin Launch", "projectRoot": "${workspaceFolder}", "mainClass": "io.mycode.ServerKt" } ] The dependency error: [INFO] main Connected to client [INFO] async1 Resolving dependencies for 'server' through Gradle's CLI using tasks [kotlinLSPProjectDeps]... [WARN] async1 Could not resolve classpath using Gradle: ClassLoader.getSystemResourceAsStream(scriptName) must not be null [INFO] async1 Could not resolve kotlin-stdlib using Maven: Cannot invoke "java.nio.file.Path.getFileSystem()" because "path" is null [INFO] async1 Successfully resolved kotlin-stdlib using Gradle [INFO] async1 Starting JVM debug session with main class io.mycode.ServerKt Error: Unable to initialize main class io.mycode.ServerKt Caused by: java.lang.NoClassDefFoundError: mu/KLogger [INFO] eventBus Sent exit event [INFO] async0 Exiting JDI session So my question is simple: what is the working config to have VScode working with a gradle/kotlin project? Debug included. Thanks
My nightwatch.js tests not runs in Chrome headless of CentOS
I run nightwatch.js tests using Nightwatch version 1.0.18 and It's working in windows environment but when I run it in centOS after installment of Xvfb I found below error. Error while running .navigateTo() protocol action: invalid session id Error while running .locateMultipleElements() protocol action: invalid session id Error while running .locateMultipleElements() protocol action: invalid session id Here is my nightwatch.json file code: { "src_folders": [ "./tests" ], "output_folder": "./reports", "custom_commands_path": "./custom_commands", "custom_assertions_path": "", "test_workers": false, "webdriver": { "start_process": true }, "test_settings": { "default": { "webdriver": { "port": 9515, "server_path": "./node_modules/chromedriver/lib/chromedriver/chromedriver", "cli_args": [ "--log", "debug" ] }, "skip_testcases_on_fail": true, "desiredCapabilities": { "browserName": "chrome", "javascriptEnabled": true, "acceptSslCerts": true, "chromeOptions": { "args": [ "headless", "no-sandbox", "disable-gpu" ] } } } } } am I missing something to run my tests in the centOS environment because it is running in the windows environment?
I had the same issue with Nightwatchjs and the npm chomedriver setup. Background: Everything was working until I just recently updated Chromium on my system. In addition to the errors in the original post, verbose logging also showed: { message: 'unknown error: Chrome failed to start: exited abnormally', error: [ "(unknown error: DevToolsActivePort file doesn't exist)", '(The process started from chrome location /usr/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.)', '(Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 4.9.0-8-amd64 x86_64)' ], } After downloading the standalone chromedriver (2.46.628388) to match my Chromium version (72.0.3626.69) it was still showing the same errors. Solution: I ended up downloading an older version of Chromium (71.0.3578.127) and setting chromeOptions.binary to the new path of the chromium 71 binary. I also had to include 'no-sandbox' with chromeOptions.args. Here is the snippet from the site mentioned above: Downloading old builds of Chrome / Chromium Let's say you want a build of Chrome 44 for debugging purposes. Google does not offer old builds as they do not have up-to-date security fixes. However, you can get a build of Chromium 44.x which should mostly match the stable release. Here's how you find it: Look in https://googlechromereleases.blogspot.com/search/label/Stable%20updates for the last time "44." was mentioned. Loop up that version history ("44.0.2403.157") in the Position Lookup In this case it returns a base position of "330231". This is the commit of where the 44 release was branched, back in May 2015.* Open the continuous builds archive Click through on your platform (Linux/Mac/Win) Paste "330231" into the filter field at the top and wait for all the results to XHR in. Eventually I get a perfect hit: https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Mac/330231/ Sometimes you may have to decrement the commit number until you find one. Download and run!
Upgrading to the latest version of chromedriver solved the issue for me. You can find the latest version here; https://www.npmjs.com/package/chromedriver
In my situation, when that error occurs: Error while running .navigateTo() protocol action: invalid session id I added the following code into .travis.yml: addons: chrome: stable
Unable to connect to a site from Testcafe IDE on OSX
My fixtures are set up like so { "fixtures": [ { "name": "login", "pageUrl": "http:\/\/localhost:3000\/", "tests": [ { "name": "type name", "commands": [ { "type": "type-text", "studio": { }, "callsite": "0", "selector": { "type": "js-expr", "value": "input[type=email]" }, "options": { }, "text": "example#email.com" } ] } ] } ] } with one simple test to find the input and type some text but when running the command I get testcafe chrome login.testcafe ERROR Unable to establish one or more of the specified browser connections. This can be caused by network issues or remote device failure. Type "testcafe -h" for help. I've seen this issue a couple of times on their issues board one relating to CI integration on a Linux server and another which seems like a similar issue of trying to connect to localhost https://github.com/DevExpress/testcafe-browser-provider-electron/issues/20 https://github.com/DevExpress/testcafe/issues/1133 New to testcafe any help would be appreciated!
I've found the solution some network policies don't allow access to your machine on some ports in my example it's 57501. testcafe chrome login.testcafe --hostname localhost adding --hostname resolves the issue documentation https://devexpress.github.io/testcafe/documentation/using-testcafe/command-line-interface.html#--hostname-name I still don't know how to launch from the IDE but this resolves my main issue.
TestCafe Studio Preview does not support setting command line options (hostname in your case). The TestCafe team is going to implement this functionality in the official release. So, for now, it is only possible to run tests via a command line. UPDATE: You can set the hostname option in the TestCafe Studio Settings dialog:
phantom JS configuration when used with InternJS
I want to use phantomJS with Intern for functional testing. I Installed phantomJS and ran the command "phantomjs --webdriver 4444", it ran successfully. Then tried to run intern-runner with the command "intern-runner config=tests/intern" -file tests/intern is shown at the end of the post-. but i keep getting the error intern-runner config=tests/intern Listening on 0.0.0.0:9000 Tunnel started Suite phantomjs on any platform FAILED UnknownError: [POST http: //localhost:4444/wd/hub/session / {"desiredCapabilities":{"browserName":"phantomjs","name":"tests/intern","idle-timeout":60}}] An unknown server-side error occurred while processing the command. on intern. and the error [ERROR - 2015-10-14T10:14:35.611Z] RouterReqHand - _handle.error - {"message":"{ \"headers\":{\"Connection\":\"close\",\"Host\":\"localhost:4444\",\"accept\":\"a pplication/json,text/plain;q=0.9\",\"content-length\":\"91\",\"content-type\":\" application/json;charset=UTF-8\",\"user-agent\":\"dojo/2.0.0-dev Node.js/4.1.2\" },\"httpVersion\":\"1.1\",\"method\":\"POST\",\"url\":\"/session\",\"urlParsed\" :{\"anchor\":\"\",\"query\":\"\",\"file\":\"session\",\"directory\":\"/\",\"path \":\"/session\",\"relative\":\"/session\",\"port\":\"\",\"host\":\"\",\"password \":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\"\",\"s ource\":\"/session\",\"queryKey\":{},\"chunks\":[\"session\"]}}","name":"Missing Command Parameter","line":85,"sourceId":65775352,"sourceURL":":/ghostdriver/req uest_handlers/session_manager_request_handler.js","stack":"Missing Command Param eter: {\"headers\":{\"Connection\":\"close\",\"Host\":\"localhost:4444\",\"accep t\":\"application/json,text/plain;q=0.9\",\"content-length\":\"91\",\"content-ty pe\":\"application/json;charset=UTF-8\",\"user-agent\":\"dojo/2.0.0-dev Node.js/ 4.1.2\"},\"httpVersion\":\"1.1\",\"method\":\"POST\",\"url\":\"/session\",\"urlP arsed\":{\"anchor\":\"\",\"query\":\"\",\"file\":\"session\",\"directory\":\"/\" ,\"path\":\"/session\",\"relative\":\"/session\",\"port\":\"\",\"host\":\"\",\"p assword\":\"\",\"user\":\"\",\"userInfo\":\"\",\"authority\":\"\",\"protocol\":\ "\",\"source\":\"/session\",\"queryKey\":{},\"chunks\":[\"session\"]}}\n at : /ghostdriver/request_handlers/session_manager_request_handler.js:85\n at :/gh ostdriver/request_handlers/session_manager_request_handler.js:44\n at :/ghost driver/request_handlers/router_request_handler.js:70","stackArray":[{"sourceURL" :":/ghostdriver/request_handlers/session_manager_request_handler.js","line":85}, {"sourceURL":":/ghostdriver/request_handlers/session_manager_request_handler.js" ,"line":44},{"sourceURL":":/ghostdriver/request_handlers/router_request_handler. js","line":70}]} on phantomjs - this error appears after running the intern-runner-. does anyone know what the problem is?. p.s. I'm using phantomJS v.1.9.8 tests/intern : define({ proxyPort: 9000, proxyUrl: 'http://localhost:9000/', environments: [ { browserName: 'phantomjs' } ], maxConcurrency: 3, useSauceConnect: false, loaders: { 'host-browser': 'node_modules/requirejs/require.js' }, tunnel: 'NullTunnel', functionalSuites: [ 'tests/functional/modetest' ], });
PhantomJS 1 is ancient (it uses a version of WebKit from 2012) and not supported. You must use PhantomJS 2+ with Intern.
Worklight Flight Ticket Sample "Function [onAuthRequired] not found."
I'm trying to run the Flight Ticket Sample Application for Worklight v6.1.0. My setup is working fine. I deployed the application as follows: I imported the project zip file FlightTicketSampleProject.zip into my workspace. I created a new web application in the server.xml file with the context root as flightticket and pointed the war location to flightticket.war. When I navigate to http://localhost:10080/flightticket I get the message simple index.html. Everything is fine so far. I then deployed the three adapters FTAdapter, FTPushAdapter and LoginAdapter to the server. Finally, I deployed the app using Run As -> Run on Worklight Development Server. When I open Worklight Console and click on Preview as Common Resources, I get an error in Eclipse console as follows: [ERROR ] FWLSE0020E: Ajax request exception: There is no application in the DB with the id 'FlightTicket'. [project module_60_4_FlightTicket] [ERROR ] FWLSE0117E: Error code: 1, error description: INTERNAL_ERROR, error message: FWLSE0069E: An internal error occurred during gadget request [project module_60_4_FlightTicket]There is no application in the DB with the id 'FlightTicket'., User Identity {wl_authenticityRealm=null, FTRealm=null, wl_remoteDisableRealm=null, SampleAppRealm=null, wl_antiXSRFRealm=null, wl_deviceAutoProvisioningRealm=null, WorklightConsole=null, wl_deviceNoProvisioningRealm=null, wl_anonymousUserRealm=null}. [project module_60_4_FlightTicket] com.worklight.common.log.filters.ErrorFilter [ERROR ] FWLSE0099E: An error occurred while invoking procedure [project module_60_4_FlightTicket]FTAdapter/onAuthRequiredFWLSE0100E: parameters: [project module_60_4_FlightTicket]{ "arr": [ { "Accept": [ "text\/javascript, text\/html, application\/xml, text\/xml, *\/*" ], "Accept-Encoding": [ "gzip, deflate" ], "Accept-Language": [ "en-IN" ], "Cache-Control": [ "no-cache" ], "Connection": [ "Keep-Alive" ], "Content-Length": [ "66" ], "Content-Type": [ "application\/x-www-form-urlencoded; charset=UTF-8" ], "Cookie": [ "testcookie=oreo; JSESSIONID=0000Ujzcx6nIYXNuXrpCFmbvqwt:040ac9eb-2103-4149-97c9-431f2113a34f" ], "Host": [ "192.168.174.1:10080" ], "Referer": [ "http:\/\/192.168.174.1:10080\/module_60_4_FlightTicket\/apps\/services\/preview\/FlightTicket\/common\/0\/default\/views\/socialShare.html" ], "User-Agent": [ "Mozilla\/5.0 (Windows NT 6.2; WOW64; Trident\/7.0; MALNJS; rv:11.0) like Gecko" ], "WL-Instance-Id": [ "8k22jp5elrdat1d06sitpqeq1f" ], "X-Requested-With": [ "XMLHttpRequest" ], "x-wl-app-version": [ "1.0" ], "x-wl-platform-version": [ "6.1.0.00.20131219-1900" ] } ] } Function [onAuthRequired] not found. I have checked the source for the onAuthRequired function but I'm not able to find either the definition nor the call to the function. Can someone tell me what's happening here?
You are just doing it wrong. Step 2 is completely not correct and no where in the Worklight documentation will you see it being asked to do. Here's what I've done and what you should follow: Downloaded the Flight Ticket sample project Imported it to Eclipse running Worklight Developer Edition 6.1 Right-clicked on each of the adapters in the adapters folder and chose Run As > Deploy Worklight adapter Right-clicked on the FlightTicket app in the apps folder and chose Run As > Run on Worklight Development Server Open Worklight Console Ran the app in the Android Emulator Step 4 is required! If you do not do this step, it means you do not deploy your application, which means your app will fail to connect to the Worklight Server. See the error message you've mentioned in the question. It tells you exactly that, that the app does not exist. After login:
Please ensure you don't delete the native folder under your Android project. The war file is used as backend server(JAX-RS), so mobile will get the data from this war file like your real enterprise data, while worklight war is auto deployed in the eclipse, and serve as the gateway for your mobile app and adaptors will connect to the backend server REST api to get mock up data.