0

I have a test file that runs every minute or second or so depending upon how I set it.

enter image description here

I set watches on variables in the file but they never populate:

enter image description here

However, I can get them to populate by setting a break point in the file itself.

Only with a break point will the variable populate.

Also, it will only populate if setInterval is called , despite the watch variable being a file wide variable - count

enter image description here

I find this behavior odd. Count should be available at all times.

1 Answers1

0

Watched variables will only be available when the script hits a breakpoint. This is just how the chrome debugger works. If you are not inside of any javascript execution then you can't reference any of your javascript variables.

EDIT: Adding a 'watched' variable is not just file-specific in devtools. It can watch any accessible javascript variable.

EDIT 2: You can output any JS variable while not in debug mode by printing out the variable through the console. Just navigate to the console tab while in developer tools and type in your variable name. The console should output the value of the variable even when you are not debugging.

R10t--
  • 803
  • 7
  • 16
  • My point was that a file variable such as count is always in memory when the server is running and should always be accessible in some way. I find it odd that I have to set a break point to view this variable. A function variable is only available when the function is running for comparison. Can you provide a reference to your answer? –  Jun 27 '19 at 21:15