Conversation
Contributor
Greptile OverviewGreptile SummaryFixed Kubernetes sandbox freezing by addressing two critical race conditions: Backend (Kubernetes Manager)
Frontend (Session Controller)
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Frontend as useBuildSessionController
participant Store as BuildSessionStore
participant KubeManager as KubernetesSandboxManager
participant RESTClient as REST ApiClient
participant StreamClient as Stream ApiClient
participant K8s as Kubernetes API
Note over Frontend: User navigates to session
Frontend->>Frontend: Check loadedSessionIdRef
Frontend->>Frontend: Set loadedSessionIdRef BEFORE async
Frontend->>Store: loadSession(sessionId)
Note over Frontend: Race condition prevented:<br/>Subsequent re-runs see ref is set
Note over KubeManager: Initialization
KubeManager->>RESTClient: Create separate REST client
KubeManager->>StreamClient: Create separate Stream client
KubeManager->>RESTClient: Assign to _core_api, _batch_api, _networking_api
KubeManager->>StreamClient: Assign to _stream_core_api
Note over KubeManager: Regular CRUD operations
KubeManager->>RESTClient: Standard API calls (list, get, create, delete)
RESTClient->>K8s: HTTP REST requests
K8s-->>RESTClient: REST responses
Note over KubeManager: Exec/Stream operations
KubeManager->>StreamClient: k8s_stream via _stream_core_api
Note over StreamClient: kubernetes.stream.stream<br/>monkey-patches this client
StreamClient->>K8s: WebSocket connection
K8s-->>StreamClient: Streaming data
Note over RESTClient,StreamClient: Clients isolated:<br/>WebSocket patch doesn't leak<br/>to REST operations
|
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="web/src/app/craft/hooks/useBuildSessionController.ts">
<violation number="1" location="web/src/app/craft/hooks/useBuildSessionController.ts:131">
P2: Setting `loadedSessionIdRef` before `loadSession` completes can block retries if the load fails, because the guard treats the session as already loaded.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
|
||
| // Set ref BEFORE any async work to prevent duplicate calls | ||
| // if the effect re-runs while we're still loading | ||
| loadedSessionIdRef.current = existingSessionId; |
Contributor
There was a problem hiding this comment.
P2: Setting loadedSessionIdRef before loadSession completes can block retries if the load fails, because the guard treats the session as already loaded.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At web/src/app/craft/hooks/useBuildSessionController.ts, line 131:
<comment>Setting `loadedSessionIdRef` before `loadSession` completes can block retries if the load fails, because the guard treats the session as already loaded.</comment>
<file context>
@@ -126,20 +126,22 @@ export function useBuildSessionController({
+ // Set ref BEFORE any async work to prevent duplicate calls
+ // if the effect re-runs while we're still loading
+ loadedSessionIdRef.current = existingSessionId;
+
// Access sessions via getState() to avoid dependency on Map reference
</file context>
wenxi-onyx
approved these changes
Jan 28, 2026
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
How Has This Been Tested?
Additional Options
Summary by cubic
Fixes Kubernetes sandbox freezes by separating REST and streaming API clients and preventing duplicate session loads in the web app. This stabilizes pod exec operations and stops “Handshake status 200 OK” errors.
Written for commit 0651dc8. Summary will update on new commits.