johnpapa / lite-server

Lightweight node server
MIT License
2.32k stars 269 forks source link

Chrome refreshing after breakpoint (break point) pause #143

Closed zatchgordon closed 5 years ago

zatchgordon commented 6 years ago

Chrome refreshing after breakpoint (break point) pause

When pausing on a break point via a the chrome debugger or via vs code and waiting more than 5 seconds (normally just inspecting an variable) and then continuing the code, chrome will refresh. I would expect chrome to not refresh and continue on with the code. The weird thing is if i continue the breakpoint immediately then chrome will not refresh. It's only when a breakpoint is stopped for and elongated period of time (5-20 seconds) that chrome will refresh.

The problem might have to do sort of with Chrome, but I've tried with IIS/visual studio and the same problem does NOT occur leading me to think it is a mix of lite-server/browsersync/chrome.

I have tried setting the browsersync settings of "watch": false "files": [""] "files": ["index.html"] but none of those seem to stop Chrome from refreshing when paused at a breakpoint for a more than a few seconds.

Bug repro steps

Here are my normal settings and edited (trying to make the refresh not happen) settings for browsersync for running with lite-server -c bsSettings.config.js

Normal settings

module.exports = {    
    "port": 44300,
    "https": true,
    "files": ["./**/*.{html,htm,css,js,ts}"],
    "server": { "baseDir": "./" },
    "open": false
}; 

New settings trying to stop the bug from happening

module.exports = {
    "port": 44300,
    "https": true,
    "files": ["index.html"],
    // "server": { "baseDir": "./" },
    // "open": false,
    watch: false,
}; 
  1. Run the command lite-server -c bsSettings.config.js
  2. Open Chrome (if not opened by default)
  3. Open chrome console
  4. Go to Sources tab
  5. Find a file to set a breakpoint on
  6. Set a breakpoint
  7. Navigate app to trigger breakpoint
  8. Wait 5, 10, 15 seconds on breakpoint
  9. Un-pause breakpoint
  10. Chrome Refreshes

Environment

fractionalJoe commented 6 years ago

+1

matsakyan commented 6 years ago

+1

royalrex commented 6 years ago

I have the same issue, but I don't use lite-server. I found this issue when searching for "stop chrome from reloading after breakpoint". After further testing, I have found that the same issue is true in Firefox, so it might be a browsersync issue. For reference I use gulp serve for development, and it triggers this issue.

EDITED: Okay, there is an open issue about this thing: https://github.com/BrowserSync/browser-sync/issues/1591#issuecomment-413621561

Work around this "bug" by adding this setting:

browserSync.init({
...
    socket: {
        clients: { heartbeatTimeout: 60000 } 
    }
...
});
zatchgordon commented 5 years ago

If setting heartbeatTimeout doesn't work... you can run

npm i -D -E browser-sync@2.23.7

as mentioned in the thread roayalrex mentioned.

This worked for me. Marking as closed.