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

Possible to add a delay to reload page? #299

Open
kfdm opened this issue Nov 27, 2024 · 2 comments
Open

Possible to add a delay to reload page? #299

kfdm opened this issue Nov 27, 2024 · 2 comments

Comments

@kfdm
Copy link

kfdm commented Nov 27, 2024

Description

This plugin works almost out of the box for me, doing exactly what is advertised, but triggers a reload too fast and I get a 500.

Since the script tag reads in the dataset entry

https://github.com/adamchainz/django-browser-reload/blob/main/src/django_browser_reload/static/django-browser-reload/reload-listener.js#L4

I'm wondering if it would be possible to add a django setting for a default timeout, that gets passed through a data-timeout (or similar) attribute, and then add an extra sleep statement to the reload section.

if (event.data === 'Reload') {
location.reload()
}

Does that sound like something reasonable to do as a pull request ?

@kfdm kfdm changed the title Possible to add a delay to restart? Possible to add a delay to reload page? Nov 27, 2024
@adamchainz
Copy link
Owner

Why do you get an error?

#222 adds a “debounce” - a timer that also groups reloads across the time frame. I think we should add that by default, perhaps 500ms or so. But the PR needs work.

@kfdm
Copy link
Author

kfdm commented Nov 29, 2024

Testing with it more, it might partially be an error with an extra proxy-server/process manager I use in front of django.
While testing it again directly with django runserver, I have trouble getting it to trigger, but when behind my proxy-server, it is just slow enough to cause the proxy server to throw the equivilant of a 500/502.

Having just a bit of delay seems to fix it for my case, but I will keep testing. Having a small delay like in #222 would likely avoid my issue. I will take a look at that PR and see what they did (I did a local test where I just naively added 1 second delay)

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

2 participants