question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Retrieving local scope from call frame

See original GitHub issue

I’m trying to retrieve the local scope data from chrome-remote-interface: image

But when logging the frame it shows this:

{
  callFrameId: '5692085564504316912.24.0',
  functionName: '$u',
  functionLocation: { scriptId: '1025', lineNumber: 3, columnNumber: 27701 },
  location: { scriptId: '1025', lineNumber: 3, columnNumber: 27729 },
  url: 'https://x/init.js',
  scopeChain: [
    {
      type: 'local',
      object: [Object],
      name: '$u',
      startLocation: [Object],
      endLocation: [Object]
    },
    {
      type: 'closure',
      object: [Object],
      startLocation: [Object],
      endLocation: [Object]
    },
    { type: 'global', object: [Object] }
  ],
  this: { type: 'undefined' },
  returnValue: { type: 'string', value: '/blocked' }
}
  {
    type: 'local',
    object: {
      type: 'object',
      className: 'Object',
      description: 'Object',
      objectId: '3902945018858753175.1.508'
    },
    name: '$u',
    startLocation: { scriptId: '9', lineNumber: 3, columnNumber: 27701 },
    endLocation: { scriptId: '9', lineNumber: 3, columnNumber: 27730 }
  }

How would you retrieve the e variable containing “pathname” from the local scope?

Component Version
Operating system Windows 10
Node.js 14.18.0
Chrome/Chromium/… Chrome 96.0.4664.45
chrome-remote-interface 0.31.1

Is Chrome running in a container? NO

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
epiccucumber15commented, Dec 2, 2021

No problem, I will just iterate over them. Thanks for the quick replies & hard work put into this interface.

0reactions
cyrus-andcommented, Dec 2, 2021

Not 100% sure, but I’m afraid you’ll have to iterate over the nested objects and call Runtime.getProperties for each of them. If you can come up with a standalone example I could maybe be more helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Getting local variables from a stack frame on the JVM
Is there any way to get a map or other data structure of the local variables in the current scope in on the...
Read more >
Scope, Frame and Stack
Once foo() is invoked, it has its own frame created on the stack, one that now has its own, 'local' scope. (Note that...
Read more >
Call Stack, Scope & Lifetime of Variables - YouTube
Concepts: Scope and Lifetime of VariablesProgram Call StackLocal and Global Variables.
Read more >
How does variables inside a local scope work? Do they get ...
From what I know, when a function is called, it gets pushed onto the stack with all its data and when its scope...
Read more >
How are variables stored in and retrieved from the program ...
Storing local variables on a stack is an implementation detail – basically an optimization. You can think of it this way.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found