Browser-sync: Option to stop polling

Created on 1 May 2015  路  9Comments  路  Source: BrowserSync/browser-sync

Been studying the API but couldn't find an option to stop polling.

Is there any?

Most helpful comment

I have to see I find the polling annoying too. And it can be easily controlled by telling Socket.IO to only use the "websocket" transport. Can this issue be reopened?

All 9 comments

I'm using the latest version on npm, v2.6.9

These are example URLs the client is polling from the server
http://xxx/browser-sync/socket.io/?EIO=3&transport=polling&t=1430435600042-95&sid=kg9Nsqrr3m1uPjukAAAC

How can I disable these with an option? The following is our current coffee code:

    browserSync(
      host:           'localhost'
      port:           config.port
      browser:        config.browser
      logLevel:       if config.debug then 'debug' else if config.browser then 'info' else 'silent'
      logConnections: if config.debug and config.browser then true else false
      logSnippet:     if config.debug and config.browser then true else false
      open:           if config.browser then true else false
      notify:         if watching and config.browser then true else false
      codeSync:       if watching and config.browser then true else false
      timestamps:     if config.browser then true else false
      ghostMode:      false # do not mirror movements to other devices
      online:         false # do not do any online checks
      server:
        baseDir: [paths.public]
        routes:
         ...
        middleware: [
          proxy(proxyOptions)
        ]
    , (err, newBs) ->
      if (err)
        cb(err)
      else
        bs = newBs

        browserSync.emitter.on('service:exit', ->
          self.emit('exit')
          if !config.debug then config.logger('Dev server shut down.')
        )

        reloadMiddleware()
        config.logger('Dev server started on localhost:' + config.port)
    )

Asking this because we sometimes want to disable the watch mode by setting watching to false.

@binarykitchen - when you say

sometimes want to disable the watch

do you mean file watching? if so, this has nothing to do with the web sockets polling

Oh, I guessed both are related. Then which option is related to the web socket polling and can disable it?

This is not something we can control (it's socket.io).

I have to ask, what's the need for this?

Because I have two gulp tasks, one for watching code for changes, and the other one just for starting up the server BrowserSync comes with while running end to end tests (e2e). Both use same, shared code.

So, when just running e2e tests, most functionality of BrowserSync is irrelevant. And the polling won't work and is polluting the browser console with too many error messages. Hence I wonder if this can be disabled.

I have to see I find the polling annoying too. And it can be easily controlled by telling Socket.IO to only use the "websocket" transport. Can this issue be reopened?

Seconding @arendjr for re-opening the issue, use case being I had a very small memory leak I was trying to isolate and the polling has a tiny memory overhead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ngryman picture ngryman  路  3Comments

npearson72 picture npearson72  路  3Comments

ronilaukkarinen picture ronilaukkarinen  路  4Comments

demisx picture demisx  路  4Comments

w88975 picture w88975  路  3Comments