Skip to content

Commit ad5dfa5

Browse files
committed
refactor: use context.WithoutCancel for token lazy-loading to prevent context cancellation issues
1 parent f94185b commit ad5dfa5

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • internal/pkg/service/appsproxy/dataapps/k8sapp

internal/pkg/service/appsproxy/dataapps/k8sapp/watcher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,9 @@ func (w *StateWatcher) GetState(ctx context.Context, appID api.AppID) (AppInfo,
130130
// Lazy-load E2B token: the Secret may not have existed when the App CRD event was processed.
131131
// a singleflight coalesces concurrent requests for the same secret into a single K8s API call.
132132
if e.e2bAccessToken == "" && e.e2bSecretName != "" {
133+
fetchCtx := context.WithoutCancel(ctx)
133134
token, err, _ := w.tokenLoadGroup.Do(e.e2bSecretName, func() (any, error) {
134-
return w.loadSecretToken(ctx, e.e2bSecretName)
135+
return w.loadSecretToken(fetchCtx, e.e2bSecretName)
135136
})
136137
if err != nil {
137138
w.logger.Warnf(ctx, "App %s: failed to lazy-load E2B access token from secret %q: %s", appID, e.e2bSecretName, err)

0 commit comments

Comments
 (0)