7

For example the variable mergedArray below.

My issue is that variables are often impossible to inspect even when defined within the current function.

I found other questions that ask something similar, but the answer in those questions relates to the variable being defined in a higher scope.

This issue is technically in Electron - but it uses what is essentially Chrome DevTools.

enter image description here

Slbox
  • 10,957
  • 15
  • 54
  • 106
  • 1
    It looks like you're trying to access `mergedArray` in your _console_ which would be the _global_ scope, no the same scope as the inline function. – Chloe Dev Aug 03 '20 at 22:23
  • 1
    So I can't hover it to inspect, watch it, or access it in the console unless I `console.log()` the variable from within my code? Seems pretty nuts and entirely inconsistent in when this is an issue and when it's not. – Slbox Aug 03 '20 at 22:36
  • It isn't inconsistent because it's only doing what you're telling it to do... debug your code properly, either by using a _global_ variable or logging the variable in the console like suggested. – Chloe Dev Aug 04 '20 at 00:31
  • 2
    Current scope is added to the console while debugging in paused state, but here the problem is likely incorrect handling of sourcemapped scripts where the variables have different real names in the actual js file. See if it's reported on https://crbug.com or report it yourself. – wOxxOm Aug 04 '20 at 03:45
  • Thanks @wOxxOm I'll take a look. – Slbox Aug 04 '20 at 19:03
  • 4
    Re: "Debug your code properly... by using a global variable" -- I don't think you're using the debugger properly @ChloeDev – Slbox Aug 04 '20 at 19:03

2 Answers2

2

try expanding the Scope pane (below or above Call Stack pane) and see what variables are listed under Local. it could be shown as a different name e.g.

enter image description here

this could be a result of minification

pref
  • 1,651
  • 14
  • 24
1

I don't have an answer for why this happens, but it can be remedied by temporarily adding a line in your code:

const variableUsuallyUnavailable = 1;

while(bool) {
  variableUsuallyUnavailable; // This will make it available in the debugger;
  // ... Your actual code
}

Not very convenient, but it's all I have to offer even after all these years.

Slbox
  • 10,957
  • 15
  • 54
  • 106