Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/frontend/src/store/frontend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class FrontendStore extends VuexModule {

backend_status_request = null as Promise<AxiosResponse> | null

last_backend_online_time: Date = new Date()

backend_offline = false

frontend_id = (() => {
Expand All @@ -32,6 +34,9 @@ class FrontendStore extends VuexModule {

@Mutation
setBackendOffline(offline: boolean): void {
if (!offline) {
Comment thread
ES-Alexander marked this conversation as resolved.
this.last_backend_online_time = new Date()
}
this.backend_offline = offline
}
}
Expand Down
6 changes: 6 additions & 0 deletions core/frontend/src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ export const isBackendOffline = (error: any): boolean => {
return false;
}

const minimum_backend_status_check_interval = 2000
Copy link
Copy Markdown
Collaborator

@ES-Alexander ES-Alexander Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const minimum_backend_status_check_interval = 2000
const minimum_backend_status_check_interval = 2000 // ms

Or in the variable name (like Sourcery suggested), if that's preferable 🤷‍♂️


const axios_backend_instance: AxiosInstance = axios.create()
axios_backend_instance.interceptors.request.use(async (config) => {
const online_recently = frontend.last_backend_online_time.getTime() + minimum_backend_status_check_interval > new Date().getTime()
if (online_recently) {
return config
}
// Check if there's already a backend status request running. If yes, use it. If not, start one.
if (frontend.backend_status_request === null) {
frontend.setBackendStatusRequest(axios.get(frontend.backend_status_url, { timeout: 5000 }))
Expand Down
Loading