Skip to content

[backport/1.4] Improve frontend 2: Deduplicate /status requests - #4064

Open
joaoantoniocardoso wants to merge 1 commit into
bluerobotics:1.4-devfrom
joaoantoniocardoso:backports/1.4/dedupe-status-requests
Open

[backport/1.4] Improve frontend 2: Deduplicate /status requests#4064
joaoantoniocardoso wants to merge 1 commit into
bluerobotics:1.4-devfrom
joaoantoniocardoso:backports/1.4/dedupe-status-requests

Conversation

@joaoantoniocardoso

Copy link
Copy Markdown
Member

This is a backport of #4026 into 1.4.

Every back_axios call used to hit /status first, which piled up under
normal polling. Cache a recent online result for 3s (same as
BackendStatusChecker) and share one in-progress check so we only
actually request when the cache is stale.
@github-actions

Copy link
Copy Markdown

Automated PR Review

0. Summary

  • Verdict: LGTM :shipit:

Backport of #4026 into 1.4-dev. Adds a 3s stale-while-revalidate cache for the /status preflight in axios_backend_instance's request interceptor so routine polling stops piling up one /status per outgoing request. When the cache is warm the interceptor returns immediately; when the TTL has expired but the backend is still marked online, a background refresh is kicked off and the current request is not blocked; on first use or after the backend has been marked offline, the code falls through to the original blocking behavior (preserving the backend_offline_error throw). The applied patch matches the master version of core/frontend/src/utils/api.ts byte-for-byte.

No further comments, nice job 👍

Generated by PR Review Bot. This is advisory, a human reviewer must still approve.

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

Successfully merging this pull request may close these issues.

1 participant