Repository navigation
feat(web): retry transient failures when fetching frontend assets and resources - #1053
Merged
Merged
Conversation
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
September 28, 2026 07:58
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a new utility function fetchWithRetry to handle automatic retries with exponential backoff on transient HTTP statuses (502, 503, 504) and network errors. This utility is integrated into the release notes component and WebGL utility functions, and several API methods are added to the retryable methods list. The changes are well-supported by comprehensive unit tests. The review feedback suggests two key improvements: extracting the AbortSignal from the input parameter if it is a Request object, and simplifying the fetch call while throwing a custom CancellationError instead of a DOMException when an abort occurs.
Merged
via the queue into
GoogleCloudPlatform:main
with commit Sep 28, 2026
c90493c
17 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background & Problem
When KHI runs behind reverse proxies or load balancers, static frontend asset requests (such as WebGL
.glslshader files, BMFont.jsonconfigurations, texture atlas images, and release notes markdown) or idempotent Connect-RPC requests occasionally encounter transient HTTP502 Bad Gateway,503 Service Unavailable, or504 Gateway Timeoutresponses, as well as brief network interruptions.Previously, raw
fetch()calls andHTMLImageElement.srcloads inWebGLUtilandReleaseNotesDialogSmartComponentdid not retry on transient failures. A single transient502when fetching a shader or font asset caused WebGL timeline canvas initialization to fail permanently until the user manually reloaded the page. Additionally, several idempotent unary Connect-RPC methods added in recent features were not registered inDEFAULT_RETRYABLE_METHODS.Solution Approach
fetchWithRetry):isRetryableHttpStatus(status)andfetchWithRetry(input, options)inretry-util.ts, reusing the existing exponential backoff with jitter (calculateBackoffDelayMs), abort-aware delay (delayWithSignal), and network error detection (isRetryableError).fetchWithRetryautomatically retries whenfetch()returns a retryable HTTP status (502,503,504) or throws a transient networkTypeError, while respectingAbortSignalcancellation and returning non-retryable responses (200,404,500, etc.) immediately without extra attempts.WebGLUtil.getShaderString,WebGLUtil.loadBMFontConfig, andReleaseNotesDialogSmartComponentto fetch assets viafetchWithRetry.WebGLUtil.loadImageto fetch image bytes viafetchWithRetry, decode the resultingBlobviaURL.createObjectURLandimage.decode(), and deterministically revoke the object URL in afinallyblock. Failed loads continue to be evicted fromimageLoadingCacheso subsequent requests can retry cleanly.GetTimelineIDsForLogs,GetInspectionTaskRegistry,ResolveInspectionTaskGraph,PullInspectionRunTaskGraph,DryRunInspection, andValidatePopupAnswer) toDEFAULT_RETRYABLE_METHODSinretry.interceptor.ts.Alternatives Considered
HTMLImageElement.srcdirectly viaonerrorcallbacks: Rejected because browserHTMLImageElementerror events do not expose the underlying HTTP status code, making it impossible to distinguish transient502/503/504responses from permanent404 Not Founderrors. Fetching viafetchWithRetryand decoding aBlobobject URL enables status-aware retries and matches the existing pattern inStyleStore.setIconAtlas.Remaining Issues & Future Work