Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome DevTools error: "Failed to save to temp variable."

I am using Node Monkey to debug my NodeJS app.

It happens frequently that when I click "Store as Global Variable" in my Chrome Console it says "Failed to save to temp variable."

enter image description here

console.log({why:'dont', you:'work?'}) 

It happens also in this jsfiddle

1) Am I doing something wrong?

2) Why this happens?

Chrome: 50.0.2661.102 (64-bit) OSX El Capitan 10.11.4

like image 364
Devid Farinelli Avatar asked Jun 01 '16 07:06

Devid Farinelli


People also ask

How do I view a variable in Chrome dev tools?

You need to double click the variable name, then right click will reveal the add to watch option.

How do I troubleshoot Chrome developer tools?

Alternatively, you can access the Chrome developer tools by clicking on the three dots at the top-right corner of the screen. Head to More tools and select Developer tools. Another option is to right-click on the web page and click on the Inspect option.

How do I debug JavaScript errors in Chrome?

Press the F12 function key in the Chrome browser to launch the JavaScript debugger and then click "Scripts". Choose the JavaScript file on top and place the breakpoint to the debugger for the JavaScript code.


1 Answers

I can see two reasons why Store As Global Variable wouldn't work:

1. Wrong Console Context Selected

This is arguably a Chrome bug, but you can only store an object as a global if the console is set to the same context as the code that logged the object.

In practice this means you might need to select the correct IFrame or web worker.

For example, on jsFiddle:

In the normal jsFiddle editor page context I'm getting an error. But it works if I change the context to the contents of the fiddle itself:

2. Garbage Collection

In order for Chrome to give you a reference to the object the object still has to be in memory. If that isn't the case it can only throw an error.

However, I'm pretty sure that being shown in the console forces V8 to keep a reference to the value.

like image 65
Matt Zeunert Avatar answered Oct 04 '22 22:10

Matt Zeunert