Lab 4.2 - Setting a Breakpoint Using a Code Keyword

Question: The labs-2 folder has an app.js file, edit the file so that when started in Inspect mode it willpause in the first line of the f function.
function f (n = 99) {
debugger
if (n === 0) throw Error()
f(n - 1)
}
f()
Problem: I have given the command 'node --inspect app.js'
My application is not stopping in line 2. Am i doing something wrong here.
Comments
-
I am having the same issue. Node version 12.19.0
0 -
Only
--inspect-brk
works at the moment.
https://github.com/nodejs/node/issues/309111 -
The same behaviour shows up when using NodeJS v12.18.4 LTS.
The--inspect-brk
option does not stop at the line withdebugger
statement but the first executing line. When continuing execution then it stops at the line with thedebugger
statement.I mentioned this in the second part of my post from October 4th which was made visible today.
https://forum.linuxfoundation.org/discussion/857623/why-do-the-dynamic-evaluation-and-debugging-examples-have-different-behaviour-on-node-v12-18-4-lts#latestBest,
Zorawar0 -
Hi @anilfred . I had the same issue. I found the solution by starting the debugger using the line "node inspect .\app.js" without the two dashes and afterwards just type in chrome --> chrome://inspect and it should stop in "debugger".
Regards,
Tassos0 -
thanks for bringing this up everyone, it does indeed seem to be a bug in Node. I'm going to reach out to core team members and see what can be done to fix it, if it continues to stall I'll update the training to work around this
1 -
I'm doing right now the Node.js Application Development (LFW211) training. So has the interface changed from --inspect to inspect as subcommand? Is there any updated training material?
0 -
@ghortat no it's not changed,
node inspect
is a command line interface,node --inspect
initialises the devtools debugging protocol that can be connected to via chrome://inspect.The problem with the specific example is there is no time between executing the command with --inspect and the runtime hitting the
debugger
statement to actually connect to the inspector protocol. The debugger statement is ignored as usual, because when using--inspect
if there's no debugger client connected, the runtime isn't in a debugging mode.So for given code example here, the only approach is to use
--inspect-brk
.Where
--inspect
is applicable is with something like an HTTP server. You can interact with the server normally, and then at some future point connect devtools to the exposed inspect interface and begin to debug it (this would also trigger any debugger statements).0 -
A possible workaround would be to use the setTimeout in the app.js instead of invoking directly the f method, something like
setTimeout(f, 5000)
And click on the chrome "inspect" link within 5 secs0 -
@giacomolm said:
A possible workaround would be to use the setTimeout in the app.js instead of invoking directly the f method, something likesetTimeout(f, 5000)
And click on the chrome "inspect" link within 5 secsThat would be a little less efficient because I don't want to wait that longer.
So I tend to use the debugger integrated in vscode when I am working on a project and want to debug some code.0 -
the course is being updated for Node 16 - the inspect-brk issue seems to be resolved in 16, use the --inspect-brk flag to pause at the first line of code.
1 -
Still the same problem on chapter 4...
Running the code with debugger keyword on line 2 and "node --inspect app.js" does not stop on line 2 as expected but throws the error.Windows 11, Node 16.14.0 via NVM
1 -
Yes,
--inspect-brk
still kinda works, but--inspect
still does not with Node 16. I say kinda because it initially stops at line 5(f()
) and once you click to resume, it then stops at thedebugger
line.Also just checked and it is also the case with Node.js v18.2.0
0 -
@schalkneethling stopping at line 5 makes sense. The debugger is stopping in the first tick before the first function call, that just happens to be on line 5. The code above it is a declaration, so it doesn't execute in the first tick.
0
Categories
- All Categories
- 49 LFX Mentorship
- 102 LFX Mentorship: Linux Kernel
- 551 Linux Foundation Boot Camps
- 295 Cloud Engineer Boot Camp
- 118 Advanced Cloud Engineer Boot Camp
- 52 DevOps Engineer Boot Camp
- 53 Cloud Native Developer Boot Camp
- 4 Express Training Courses
- 4 Express Courses - Discussion Forum
- 1.9K Training Courses
- 18 LFC110 Class Forum
- 6 LFC131 Class Forum
- 25 LFD102 Class Forum
- 150 LFD103 Class Forum
- 17 LFD121 Class Forum
- LFD137 Class Forum
- 61 LFD201 Class Forum
- LFD210 Class Forum
- LFD210-CN Class Forum
- 1 LFD213 Class Forum - Discontinued
- 128 LFD232 Class Forum
- LFD237 Class Forum
- 23 LFD254 Class Forum
- 596 LFD259 Class Forum
- 102 LFD272 Class Forum
- 1 LFD272-JP クラス フォーラム
- LFD273 Class Forum
- 2 LFS145 Class Forum
- 24 LFS200 Class Forum
- 739 LFS201 Class Forum
- 1 LFS201-JP クラス フォーラム
- 3 LFS203 Class Forum
- 69 LFS207 Class Forum
- 300 LFS211 Class Forum
- 54 LFS216 Class Forum
- 47 LFS241 Class Forum
- 41 LFS242 Class Forum
- 37 LFS243 Class Forum
- 11 LFS244 Class Forum
- 33 LFS250 Class Forum
- 1 LFS250-JP クラス フォーラム
- LFS251 Class Forum
- 140 LFS253 Class Forum
- 1K LFS258 Class Forum
- 10 LFS258-JP クラス フォーラム
- 92 LFS260 Class Forum
- 129 LFS261 Class Forum
- 32 LFS262 Class Forum
- 79 LFS263 Class Forum
- 15 LFS264 Class Forum
- 11 LFS266 Class Forum
- 17 LFS267 Class Forum
- 17 LFS268 Class Forum
- 23 LFS269 Class Forum
- 203 LFS272 Class Forum
- 1 LFS272-JP クラス フォーラム
- LFS281 Class Forum
- 221 LFW211 Class Forum
- 166 LFW212 Class Forum
- SKF100 Class Forum
- 901 Hardware
- 219 Drivers
- 74 I/O Devices
- 44 Monitors
- 115 Multimedia
- 208 Networking
- 101 Printers & Scanners
- 85 Storage
- 761 Linux Distributions
- 88 Debian
- 66 Fedora
- 15 Linux Mint
- 13 Mageia
- 24 openSUSE
- 141 Red Hat Enterprise
- 33 Slackware
- 13 SUSE Enterprise
- 356 Ubuntu
- 477 Linux System Administration
- 41 Cloud Computing
- 69 Command Line/Scripting
- Github systems admin projects
- 95 Linux Security
- 77 Network Management
- 108 System Management
- 49 Web Management
- 66 Mobile Computing
- 23 Android
- 29 Development
- 1.2K New to Linux
- 1.1K Getting Started with Linux
- 536 Off Topic
- 131 Introductions
- 216 Small Talk
- 21 Study Material
- 816 Programming and Development
- 275 Kernel Development
- 507 Software Development
- 928 Software
- 260 Applications
- 184 Command Line
- 3 Compiling/Installing
- 76 Games
- 316 Installation
- 59 All In Program
- 59 All In Forum
Upcoming Training
-
August 20, 2018
Kubernetes Administration (LFS458)
-
August 20, 2018
Linux System Administration (LFS301)
-
August 27, 2018
Open Source Virtualization (LFS462)
-
August 27, 2018
Linux Kernel Debugging and Security (LFD440)