Repository navigation
feat(api): add polling fallback APIs for streaming RPCs and transparent interceptor - #912
Merged
Merged
Conversation
…nt interceptor Support non-streaming hosting environments (such as App Engine Standard) by introducing unary polling fallback RPCs and a transparent client-side Connect-RPC interceptor. - Define paired polling RPCs in Protobuf (PullPopup, PullServerStat, PullInspections, PullIndexProgress, OpenWorkbenchSync, FilterTimelineSync, and associated cancellation RPCs). - Implement StateObserver and AsyncJobManager in pkg/server/streamingutil for lifecycle management, progress caching, 15s abandonment cancellation, and 1m TTL eviction. - Implement legacy-polling.interceptor in frontend to transparently adapt streaming RPCs into polling unary calls without modifying caller code. - Add streaming-api skill documenting API classification, naming rules, and interceptor patterns. - Remove deprecated and redundant GetServerStat RPC.
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
August 26, 2026 14:44
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a transparent polling fallback mechanism for Server-Side Streaming RPCs to support non-streaming hosting environments. It adds paired unary polling RPCs, implements an AsyncJobManager and state observation utilities on the backend, and introduces a frontend Connect interceptor to map streaming calls to polling unary calls. A review comment identifies a potential data race in pkg/server/streamingutil/async_job.go where prev.isDone is accessed without acquiring the read lock.
…ybook mock - Acquire prev.mu.RLock() before checking prev.isDone in AsyncJobManager.Poll to prevent a data race with background job completion. - Add pullPopup method to mockClient in text-popup-content.stories.ts to satisfy Client<typeof PopupService> interface.
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.
Description
In hosting environments such as Google App Engine Standard or restricted HTTP proxy environments, persistent HTTP/2 and gRPC server-side streaming connections may be buffered, terminated prematurely, or unsupported.
This PR introduces unary polling counterpart APIs alongside existing Server-Side Streaming RPCs, accompanied by a transparent client-side Connect-RPC interceptor. Frontend callers (UI and services) continue using standard streaming patterns (
for await (const res of ...)) without modification, while the interceptor transparently routes calls to unary polling RPCs when legacy polling mode is enabled.Changes
1. Protobuf Definitions
PullPopup,PullServerStat,PullInspections,PullIndexProgressOpenWorkbenchSync/CancelOpenWorkbenchSync,FilterTimelineSync/CancelFilterTimelineSyncGetServerStatRPC fromServerStatusService.2. Backend Implementation
StateObserver: Utility for tracking snapshot state updates and broadcasting changes.AsyncJobManager: Lifecycle manager for asynchronous background tasks, supporting job-id tracking, progress caching, 15-second abandonment timeout cancellation, 1-minute TTL cache eviction, and automatic cancellation of superseded jobs on new query requests.PullPopup,PullServerStat,PullInspections,PullIndexProgress,OpenWorkbenchSync,CancelOpenWorkbenchSync,FilterTimelineSync, andCancelFilterTimelineSync.Workbench.Close.3. Frontend Implementation
legacy-polling.interceptor.ts):AsyncIterable<Response>.iterator.next()to prevent premature iterator cancellation (TypeError: obj[k] is not a function).CancelXXXSync) whenAbortSignalis aborted.connect-client.service.ts.usePollingLegacyflag inenvironment.ts,environment.prod.ts, andenvironment.dev.ts.?pollLegacy=trueURL query parameter.4. Documentation & Guidelines
.agents/skills/streaming_api/SKILL.mddocumenting API classification, naming rules, lifecycle management, and interceptor patterns.5. Tests
StateObserverandAsyncJobManager.Pull*and*SyncRPC endpoints inpopup_test.go,server_status_test.go,inspection_test.go, andworkbench_test.go.legacy-polling.interceptor.spec.tscovering all streaming adapters, polling cycles, and abort cancellations.