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

Configurable polling timeout in watch.browser #52

Open
Messj1 opened this issue Mar 17, 2021 · 4 comments · May be fixed by #58
Open

Configurable polling timeout in watch.browser #52

Messj1 opened this issue Mar 17, 2021 · 4 comments · May be fixed by #58
Assignees
Milestone

Comments

@Messj1
Copy link

Messj1 commented Mar 17, 2021

Hi

Nice project. Love the modular architecture. 👍

One thing i was missing was an configurable timeout. Would be nice in production mode to have bigger polling timeout than in development since it get then changed less often. 😉

So in watch.browser.js the hard coded value should be replaced by a variable, maybe a function parameter.

Then it could be implemented as a setting parameter:

var settings = grab(this, 'settings', {})
name = settings[name] && settings[name].config || name

BTW: There seems to be a bug 🐛 in the code. The interval get not stopped if someone call ulog.set("log_config", {});

set: function(name) {
if (name === 'log_config') config.update(this)

Maybe a destructor callback would do the trick. At the end, watch.browser.js would look something like that:

module.exports = function(ulog, pollingTimeout) {
  const intervalId = window.setInterval(watchFnc, pollingTimeout);
  return () => {
      window.clearInterval(intervalId);
  }
}
@Download
Copy link
Owner

Hi @Messj1 Yes a configurable timeout is definitely a good idea! Thanks for your report! It sounds like you already have a pretty good idea of the code changes you wanr ro make. Would you like to try to implement this? I can help you of course if you have questions.

@Download Download added this to the v2 milestone Mar 30, 2021
@Download Download self-assigned this Mar 30, 2021
@Download Download changed the title [FEATURE][BUG] configurable polling timeout in watch.browser Configurable polling timeout in watch.browser Mar 30, 2021
@Messj1 Messj1 linked a pull request Apr 3, 2021 that will close this issue
@Messj1
Copy link
Author

Messj1 commented Apr 3, 2021

@Download I'm not sure why there are two nested setTimeout in the interval function. Is there a reason to use asynchronous function call?

setTimeout(function(){
var changed = update(ulog.config, cfg)
if (changed.length) setTimeout(function(){
notify(ulog, changed)
}, 0)
}, 0)

@Download
Copy link
Owner

Download commented Apr 7, 2021

Ah yes. This is not pure, but there is an issue with the notify sometimes taking too long, so I tried to split up the work. Chrome complains sometimes about setTimeout handler taking too long to complete. This happens when it hovers around the 50ms mark.

@Messj1
Copy link
Author

Messj1 commented Apr 7, 2021

@Download I think this doesn't work since it seems to be a problem with the ext core function in notify 🤨

ulog - watch browser performance

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

Successfully merging a pull request may close this issue.

2 participants