pollUntilSetupDone tickets every bootstrapPollInterval and returns nil the first time CheckSession reports setup_required: false. Returns ctx.Err() on caller cancellation, a wrapped timeout error after bootstrapPollTimeout elapses inside the helper. Transient CheckSession errors are tolerated — we k
(ctx context.Context, client *Client)
| 226 | // (DeadlineExceeded or Canceled) instead of being misreported as the |
| 227 | // helper's own 5-minute timeout. |
| 228 | func pollUntilSetupDone(ctx context.Context, client *Client) error { |
| 229 | timeout := time.NewTimer(bootstrapPollTimeout) |
| 230 | defer timeout.Stop() |
| 231 | |
| 232 | ticker := time.NewTicker(bootstrapPollInterval) |
| 233 | defer ticker.Stop() |
| 234 | |
| 235 | for { |
| 236 | select { |
| 237 | case <-ctx.Done(): |
| 238 | return ctx.Err() |
| 239 | case <-timeout.C: |
| 240 | return fmt.Errorf("timed out waiting for setup after %s. Re-run when finished, or use --cli-prompt for the legacy TTY flow", bootstrapPollTimeout) |
| 241 | case <-ticker.C: |
| 242 | session, err := client.CheckSession() |
| 243 | if err != nil { |
| 244 | // Transient — keep polling. A stable disconnect will surface as |
| 245 | // the timeout above; a one-off will recover on the next tick. |
| 246 | continue |
| 247 | } |
| 248 | if !session.SetupRequired { |
| 249 | return nil |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | } |
no test coverage detected