MCPcopy Create free account
hub / github.com/github/gh-aw / CheckForUpdatesAsync

Function CheckForUpdatesAsync

pkg/cli/update_check.go:247–276  ·  view source on GitHub ↗

CheckForUpdatesAsync performs update check in background (best effort) This is called from compile command and should never block or fail the compilation The context can be used to cancel the update check if the program is shutting down

(ctx context.Context, noCheckUpdate bool, verbose bool)

Source from the content-addressed store, hash-verified

245// This is called from compile command and should never block or fail the compilation
246// The context can be used to cancel the update check if the program is shutting down
247func CheckForUpdatesAsync(ctx context.Context, noCheckUpdate bool, verbose bool) {
248 // Run check in goroutine to avoid blocking compilation
249 go func() {
250 // Recover from any panics in the update check
251 defer func() {
252 if r := recover(); r != nil {
253 updateCheckLog.Printf("Panic in update check (recovered): %v", r)
254 }
255 }()
256
257 // Check if context was cancelled before starting
258 if ctx.Err() != nil {
259 updateCheckLog.Printf("Update check cancelled before starting: %v", ctx.Err())
260 return
261 }
262
263 checkForUpdates(noCheckUpdate, verbose)
264 }()
265
266 // Give the goroutine a small window to complete quickly
267 // This allows the message to appear before compilation starts
268 // but doesn't block if the check takes longer
269 select {
270 case <-time.After(100 * time.Millisecond):
271 // Continue after timeout
272 case <-ctx.Done():
273 // Context cancelled during wait
274 return
275 }
276}

Calls 3

checkForUpdatesFunction · 0.85
DoneMethod · 0.80
PrintfMethod · 0.45