Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

browsersync reloads the browser when connection is restored (even though it doesn't need to reload) #1595

Closed
2 of 10 tasks
deefeloper opened this issue Aug 24, 2018 · 5 comments

Comments

@deefeloper
Copy link

Issue details

When a page has a high load (eg it takes 30 seconds to render) browsersync will have lost it's connection and on reconnect it refreshes, this keeps on going until the server is stopped

Steps to reproduce/test case

use browsersync, make a page do some heavy lifting for 30 seconds then watch as the page keeps refreshing just after crunching for a while

Please specify which version of Browsersync, node and npm you're running

  • Browsersync [ 2.24.6 ]
  • Node [ 8.11.4 ]
  • Npm [ 5.6.0 ]

Affected platforms

  • linux
  • windows
  • OS X
  • freebsd
  • solaris
  • other (android on samsung galaxy tab 3)

Browsersync use-case

  • API
  • Gulp
  • Grunt
  • CLI

If CLI, please paste the entire command below

{cli command here}

for all other use-cases, (gulp, grunt etc), please show us exactly how you're using Browsersync

  browserSync
    .init({
      server: distDir,
      ghostMode: false,
      reloadOnRestart: false,
      port: params.port || config.browserSyncPort || 3000,
      open: (typeof params.openBrowser === 'boolean') && params.openBrowser || config.openBrowser || false,
      middleware: function (req, res, cb) {
        // When using multiple languages, the root does not contain html files
        if (hasMultipleLocales && req.url === '/') {
          res.writeHead(302, { 'Location': `/${config.defaultLanguage || 'en'}/` });
          res.end();
          req.url = `/${config.defaultLanguage || 'en'}/`;
          return;
        }

        if (req.url.indexOf('.') > -1) {
          return cb();
        }

        const uri = url.parse(req.url);

        if (
          uri.pathname.length > 1
          && path.extname(uri.pathname) === ''
          && fs.existsSync(path.join(distDir, uri.pathname + '.html'))
        ) {
          req.url = uri.pathname + '.html' + (uri.search || '');
        }

        cb();
      }
    });
@travomic
Copy link

I was experiencing something similar, and seemingly resolved it by increasing the init config object's socketio clients.heartbeatTimeout to be a minute.
e.g:

  ...
  socket: {
    clients: {
      heartbeatTimeout: 60000
    }
  }

@deefeloper
Copy link
Author

Thanks for your quick reply @travomic, this might be exactly what I was looking for. I am currently not at work but I will give this a shot next monday morning and report my findings.

@gama410
Copy link

gama410 commented Aug 28, 2018

I noticed the same thing starting with 2.24.5 also! For me, it would appear when staying on any breakpoint longer than heartbeatTimeout... Changing the timeout value indeed helped...

I find it strange that the problem didn't occur prior to 2.24.5, actually...

@deefeloper
Copy link
Author

deefeloper commented Sep 5, 2018

@travomic I just noticed my comment was not sent (tried that a week ago on my phone).

Setting the heartbeatTimeout option actually resolves the issue.

If you want you can close this issue and archive it for future reference since this is not something you can really do much about (browsers dropping sockets because of timeouts).

@shakyShane
Copy link
Contributor

fixed in browser-sync-client@2.26.0 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants