Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome debugger doesn't stop

I have added a breakpoint to the following code in line 44 debugger;. I expected chrome to stop there every time before console.log("...") is executed. But to my surprise it stops only one time.

To test the example:

  1. Run the snippet below in Chrome
  2. Open Chrome Dev Tools
  3. Drag an image from another website in the drop area

At this point chrome stops at the breakpoint. But if you look in the console you should see that the console.log statement was executed two more times.

I would like to know why this happens. (Threading issue??)

And how I can solve this if I want to debug the code at this line.

$(document).ready(function() {

  $('#drop-area').on("dragover", function(event) {
    event.preventDefault();
    event.stopPropagation();
    $(this).addClass('dragging');
  });

  $('#drop-area').on("dragleave", function(event) {
    event.preventDefault();
    event.stopPropagation();
    $(this).removeClass('dragging');
  });

  $('#drop-area').on("drop", function(event) {
    event.preventDefault();
    event.stopPropagation();

    var count = 1;
    var dropObj = event.originalEvent.dataTransfer;
    for (var i = 0; i < dropObj.items.length; i++) {
      var aDropItm = dropObj.items[i];
      if (aDropItm.kind == "file") {
        //ignore
      } else {
        aDropItm.getAsString(function(_str) {
          debugger; //The debugger should stop here every time before the string is printed to the console
          console.log("This was called [" + count++ + "] times");
        });
      }
    }
  });

});
#drop-area {
  background-color: red;
  width: 400px;
  height: 400px;
}
<div id="drop-area">Drop files here...</div>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

EDIT
I reported this as a bug here: https://bugs.chromium.org/p/chromium/issues/detail?id=748923

like image 666
Lars Avatar asked Jul 25 '17 13:07

Lars


People also ask

How do I stop debugging in Chrome?

Go to the "Sources" tab. At the top right hand side, toggle the button that looks like the pause symbol surrounded by a hexagon (button on the far right) until the color of the circle turns black to turn it off. If the pause symbol isn't blue it may be that you've accidentally marked a line for debugging inspection.

How do I stop the debugger?

To end a debugging session in Microsoft Visual Studio, from the Debug menu, choose Stop Debugging.

How do I fix debug pause?

It is a simple matter to bypass the default pauses when starting a project for debugging. Simply open the debug configuration window by clicking on the gear icon as shown below. Select the "Startup" tab. Simply uncheck the "Set Breakpoint at" box and check the "Resume" box, then click OK.

How do I stop script execution in Chrome?

Open the Sources panel in Developer Tools ( Ctrl + Shift + I **). Click the Pause button to Pause script execution.


1 Answers

The issue doesn't happen anymore. It seems like it was a bug in chrome.

like image 117
Lars Avatar answered Oct 13 '22 00:10

Lars