Protractor Debugging Issue - Waiting for the debugger to disconnect - node.js

I am trying to debug protractor scripts on VSCode.
I edited the launch.json file but the debug console throws the below error.
Here is the VSCode Debug Console Output:
C:\Program Files\nodejs\node.exe --inspect-brk=45448 conf.js C:\Users\abc\AppData\Roaming\npm\node_modules\protractor\example/conf.js
Debugger listening on ws://127.0.0.1:45448/ab61a2d7-4b40-456b-86cb-838e94dfe5b0
Debugger attached.
Waiting for the debugger to disconnect...
I am not able to find a solution anywhere online either.

When you set your breakpoint in VSCode, you'll need to run the following:
node --inspect-brk ./node_modules/.bin/protractor conf.js
The path above assumes Protractor is installed in your node_modules/.bin/ directory locally in your project.
Next navigate to chrome://inspect. You will have to skip the entry point of Protractor and then you should hit your breakpoint. Make sure you are using node 8 to avoid getting polyfill-ed promises.
We go over this in detail in the ng-conf video. We kick off the test with a script that uses this e2e-debug command which is the equivalent to the above.

Related

VSCode's Auto Attach is not toggling for Node.js

I use WSL to start VSCode with code . from my project directory in Windows Terminal. When VSCode starts up, "Auto Attach: Off" is shown in the status bar:
Clicking "Auto Attach: Off" in the status bar does not toggle it.
I then start my project in VSCode's integrated terminal with npm run debug, which corresponds to the following scripts line in package.json:
"scripts": {
"debug": "NODE_ENV=development DEBUG='knex:*' nodemon --inspect ./server.js"
}
However, the debugger is not auto-attached, so I need to manually run the Attach configuration from the Run panel shown on the left here:
The debugger works, but I still cannot toggle the Auto Attach: Off to be On instead:
Even if I Ctrl+Shift+P --> Debug: Toggle Auto Attach, nothing happens. Even if I restart VSCode after doing so.
So, in conclusion, how can I start my VSCode with code . from Windows Terminal and then just type npm run debug and have VSCode, run my program AND auto-attach the debugger? I also need the server to restart upon file changes, which is why I am using nodedemon in the npm run debug script.
Do I need to either:
change launch.json configuration? Though I have tried essentially all of the boilerplate launch.json configs shown in VSCode, but none worked.
or modify my package.json defined script for debug?
or correct some setting on VSCode?

Issues with breakpoints in ts-node

I faced a very strange problem. I have two working PC and one of them stop breaking on the breakpoints in one day. Another PC works properly the same as before.
I tried to reinstall Node JS, ts-node and then even hard reset for windows (I use Windows) but without any success.
Then I thought that probably issue in my project and I tried to clone hello world project from google tutorial and I found that I still can't debug with it!
So I successfully run an app on my port but breakpoint won't hit. This stop working in VS Code, in WebStorm and even Chrome debugger.
This is how I run an app: "C:\Program Files\nodejs\node.exe" --inspect --require ts-node/register C:\Projects\node-typescript-starter-master\src\index.ts
Then I opened dev tools from chrome and I see this:
Then I pressed "inspect" and I see message in console:
Debugger attached. Debugger listening on ws://127.0.0.1:9229/8bae9408-867c-4278-9148-b6c90b35a8ae For help, see: https://nodejs.org/en/docs/inspector Debugger attached.
This is the next window. Seems like I missing any files overhere.
Does this mean that something is wrong with my file mapping ?
Please, let me any suggestion what can be a problem.
Well, one of workaround is to don't use ts-node and just use default node js debugger config from WebStorm with adding TypeScript prelaunch compilation script.
Here is a screenshot how to configure:

WebStorm debugger does not attach on first time

When debugging a Node.js script with WebStorm, this is what my script looks like (windows):
"debug": "npm run build && node %NODE_DEBUG_OPTION% ./dist/server.js"
In the console I can see that npm run build executes as usually with success. Then there is a red message that states the following
Debugger listening on ws://127.0.0.1:51311/0064d764-16b8-4b45-bdff-5a1732e9ee62
For help see https://nodejs.org/en/docs/inspector
I can wait as long as I want - WebStorm won't attach and the ./dist/server.js script is never executed. When I stop execution and re-run the script, it succeeds and the debugger attaches.

Nuclide debugger with node and babel?

I've been trying to use Nuclide/Atom to launch and debug a unit test that uses Babel and ES6+ code. The launch config looks like this:
Node runs the unit test as if I had run it from the command-line, and does not stop at my breakpoints. If I use the same invocation at the command-line with --inspect-brk I can debug correctly (with sourcemaps) from the chrome-devtools url in Chrome. Is there a way to make this work? I can't really "attach" since the unit tests are, and should be, a straight-shot script execution.
Nuclide currently does not support the new v8 Inspector protocol for debugging. You will need to use --debug flag to debug with Nuclide. Note, however, that the old debugger protocol has been removed from Node.js starting with Node.js 8.0.
PS. You can attach to a running Node.js process with Nuclide debugger just fine - just start your tests with node --debug --debug-brk ... and then attach the debugger from Nuclide. The test process will be stopped at first line, allowing you to resume execution at your own convenience.

node inspector -brk not working

I am trying to use node-inspector with a simple script. I have some console logs in place so I can tell if it's running or not. I have tried 2 ways:
node-debug test.js
With this approach, the debugger opens in chrome, but does not break and runs without giving me a chance to enter break points.
In terminal window #1:
~ $ node-inspector
Node Inspector v0.9.2
Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.
Open debugger in chrome. In terminal window #2:
node --debug-brk test.js
The script seems to be waiting, but the debugger window I opened has nothing going on, So I refresh the page. As soon as I do, I see my console logs (not breaking).
I'm running OSX Yosemite (10.10.1), Node.js v0.12.0, NPM 2.5.1, and Node-inspector v0.9.2.
Any ideas why this is happening?
This is a known bug when running on Node v0.12 and io.js, see https://github.com/node-inspector/node-inspector/issues/534

Resources