Can not start debugger with tesseract.js - node.js

I cannot start debugger in WebStorm using tesseract.js. The error is:
Starting inspector on 127.0.0.1:58767 failed: address already in use
events.js:174
Running is working correctly. Could you help me to debug?

This is an issue with tesseract.js - it doesn't pass execArgv to the child process when spawning it. child_process.fork() accepts a execArgv option that defaults to process.execArgv when omitted - as a result, the debugger for a child process is started on the same port as the parent process debugger, causing EADDRINUSE. See https://github.com/naptha/tesseract.js/issues/66,
https://github.com/naptha/tesseract.js/issues/102

Related

Is it possible to debug node js code that runs before the debugger attaches?

Using the instructions found here I have setup Visual Studio Code to debug my nodejs code.
But it takes the debugger a few seconds to attach to node. And during that few seconds the code just runs.
So a file like this, with a breakpoint on line 1:
• 1 console.log('')
Will never break because it quits before the debugger attaches.
I can quickly ^c the code then restart and sometimes catch the debugger but this is unreliable.
Is there an event I can wait for in my code so that I know the debugger is attached and it is safe to continue?
Or is there a better configuration for doing this?
Yes, using the --inspect-brk option for node instead of --inspect.
so when running your code it would look something like this
node --inspect-brk server.js

NodeJS debug Starting inspector on 127.0.0.1:42457 failed: address already in use error

I am trying to debug my Discord bot using the DiscordJS lib. My trouble is that when I start a debug session (launching with vscode or with --inspect-brk | --debug-brk)
I get a Starting inspector on 127.0.0.1:42457 failed: address already in use error I have tried changing the port in both situations and still getting the same error on different ports. My bot is sharded so its start child process of itself. I have tried using vscode to attach to child processes but still the same error.
If anybody is familiar with DiscordJS and knows how to debug a sharded bot some help would be much appreciated
In my case to solve this, just add that config on nodemon.json
{
"execMap": {
"js": "node --inspect=9300 -r sucrase/register"
}
}
I added --inspect=9300 to set port to this specific port
First Ctrl C (or Cmd C) to quit all your progress in the cmd.
Start Task Manager > Find all tasks named "node" > End process.
Now go back to your cmd and start server.
That is because you are already running that application in with node filename.js, hence stop that process and start with debugging again with same port.
You can take a look that on the below video might help
https://www.youtube.com/watch?v=b8e9RAekktY&t=28s

IntelliJ Node.js debug process exit -1

I've setup a project in IntelliJ 13 to run my nodeJS app. It runs fine. The problem is I can't use the debugger. When I try to run in debug mode the console prints
"C:\Program Files\nodejs\node.exe" --debug-brk=50839 --debug app.js
debugger listening on port 50839
Process finished with exit code -1
The console tab displays "Process disconnected unexpectedly"
I had the same error with debug mode ("Process finished with exit code -1073741510")
The problem was solved when I removed old watches from watch list. Debugger seems to be sensitive to those garbage watches.
It's a generic error that doesn't really provide any meaningful information.
I had the same issue today on Mac OSX and I finally discovered it was a combination of the new-relic package with "Break on Exception" option enabled that crashed the node app each time I started the debugger.
I hope this helps.

nodejs start debugger on different port

Im a little confused with all this nodejs debug syntax flying around.
I simply want to start the debugger on a process when I run it on a different port.
Normally I start debugging by node debug file.js
but now I have to process` running that I need to debug
Now I found the command node --debugger=7873 file.js but that starts the debugger and jumps past all the breaks and I tried node --debugger=7837 --debug-brk file.js but that forces me to consume another teminal window. How can I just run a script on a different port in the same terminal or with out using nohup?
node debug --port=[your port] your_program.js
responsible _debugger code here

debugging node.js child_process fork example on IntelliJ IDEA

I am trying to debug the child_process example from here using IntelliJ IDEA 12.1.3 and node 10.10. When I run nodejs app.js from a terminal everything works. The console output displays as expected. However, when I debug the same script using IDEA there are no messages in console output and the app just sits there. This is what is in the console window:
/usr/bin/nodejs --debug-brk=58954 app.js
debugger listening on port 58954
debugger listening on port 58954
When I run the script in IDEA without the debugger attached, the script works as expected.
Why does attaching the debugger break the script?
You can force the children to use a free port for debugging. InteliJ will automatically pick up the port chosen by the child process.
Here's an example:
// Determine if in debug mode.
// If so, pass in a debug-brk option manually, without specifying port.
var startOpts = {};
var isInDebugMode = typeof v8debug === 'object';
if(isInDebugMode) {
startOpts = {execArgv: ['--debug-brk']};
}
child_process.fork('./some_module.js', startArgs, startOpts);
looks like a bug in node.js fork to me: both parent and child processes receive --debug-brk=58954 switch and attempt to start debugger and listen port 58954.

Resources