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
Refresh client hourly when inactive #4648
Refresh client hourly when inactive #4648
Conversation
8d4b110
to
865ba86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should get a little bit better logic in here:
- ensure we'll only refresh when there's a new client
- ensure we won't do it if the user is currently active (not hidden)
As of #4649 and a tiny HTTP handler, https://dark-editor.builtwithdark.com/latest-backend-build-hash is now available. Given that, and this conversation, my current plan for this is:
|
7632b50
to
f610b76
Compare
client/src/api/API.res
Outdated
// beginning of the function, we still exercise the message and request generating | ||
// code locally. | ||
if m.origin == "https://darklang.com" { | ||
// TODO: test this locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My local testing so far has been to raise the RefreshClientIfOutdated
Msg with a known-incorrect build hash. I suppose the next step, to better test, will be to set up a tunnel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good.
However, I think the ordering is wrong, leading it to do the API call every minute instead of every hour.
What it does:
- each minute check if there's a new client
- then checks if it's safe to update to it
What it should do:
- check if we're in a position to update (eg it's been an hour)
- then check if there is an update
Updated - do you mean like this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
Changelog:
How this works:
appsupport.js
listens for changes in whether the page is in focus or not, withwindowFocusChange
BrowserSubscription
in ReScript land, which in turn triggers aPageVisibilityChange
Msg
PageVisibilityChange
Msg
, which results in an update to apageVisibility
field in our mainmodel
PageVisibility
now has asince
field in it, which is used to track how long it's been since a page became hiddenCheckIfClientIsOutdated
Msg
; that results in an API call being made to a new endpoint indark-editor
, made possible by Add DarkInternal::serverBuildHash fn that returns the git hash of the server's current deploy #4649:[1] later, we can/should expand this criteria - currently, only the
Architecture
andFocusedPackageManagerFn
pages are considered safely refreshableI ran into some confusion when trying to tunnel my static assets in prod, so wrote some external docs in
darklang/docs
, and referenced those in the relevant portion of the Contributor settings.