Skip to content

fix: Start should panic insteal of only print#1371

Merged
hwbrzzl merged 4 commits intov1.17.xfrom
bowen/optimize-start
Feb 7, 2026
Merged

fix: Start should panic insteal of only print#1371
hwbrzzl merged 4 commits intov1.17.xfrom
bowen/optimize-start

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Feb 6, 2026

Greptile Overview

Greptile Summary

Changed Application.Start() to panic when runners fail instead of just logging errors. The implementation collects all runner errors with thread-safe mutex protection and uses errors.Join() to combine them into a single panic.

Key changes:

  • Added error collection slice with mutex for thread-safe concurrent access
  • Replaced color.Errorf with proper logging via MakeLog()
  • Added r.cancel() call on runner failure to trigger graceful shutdown of other runners
  • Panic with combined errors after all runners complete via runnerWg.Wait()
  • Comprehensive test coverage added with 6 test cases covering single/multiple runners and various failure scenarios

Critical issue identified: Restart() method (line 214) calls Start() in a goroutine, which means the new panic behavior won't be caught and could crash the application unexpectedly instead of returning an error from Restart().

Confidence Score: 2/5

  • This PR has a critical bug that could cause unexpected application crashes
  • While the core change is well-implemented with proper thread-safety and comprehensive tests, there's a critical issue in the Restart() method that calls Start() in a goroutine without panic recovery. This means runner failures will crash the entire application instead of being handled by Restart(). The new panic behavior is a breaking change that needs careful consideration of all call sites.
  • Pay close attention to foundation/application.go line 214 where Restart() calls Start() in a goroutine

Important Files Changed

Filename Overview
foundation/application.go Changed Start() to panic on runner failures instead of just logging. Added error collection with mutex protection and calls cancel() on failure. Critical issue: Restart() calls Start() in goroutine which won't catch panics.
foundation/application_test.go Added comprehensive test coverage for panic behavior including multiple runners, mixed scenarios, and proper panic assertions. Tests correctly verify the new panic behavior.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant Application
    participant Runner1
    participant Runner2
    participant ErrorCollector
    participant Logger

    Caller->>Application: Start()
    activate Application
    
    Note over Application: Initialize error slice & mutex
    
    par Run all runners
        Application->>Runner1: run(runner1)
        activate Runner1
        Runner1->>Runner1: Run()
        alt Run fails
            Runner1->>ErrorCollector: Lock & append error
            Runner1->>Logger: Log error (if available)
            Runner1->>Application: cancel()
            Runner1->>Application: runnerWg.Done()
        else Run succeeds
            Note over Runner1: Blocking until shutdown
        end
    and
        Application->>Runner2: run(runner2)
        activate Runner2
        Runner2->>Runner2: Run()
        alt Run fails
            Runner2->>ErrorCollector: Lock & append error
            Runner2->>Logger: Log error (if available)
            Runner2->>Application: cancel()
            Runner2->>Application: runnerWg.Done()
        else Run succeeds
            Note over Runner2: Blocking until shutdown
        end
    end
    
    Note over Application: Wait for all runners (runnerWg.Wait())
    
    alt Errors collected
        Application->>Application: panic(errors.Join(errs...))
        Application-->>Caller: panic!
    else No errors
        Application-->>Caller: return normally
    end
    
    deactivate Runner1
    deactivate Runner2
    deactivate Application
Loading

@hwbrzzl hwbrzzl requested a review from a team as a code owner February 6, 2026 09:33
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 6, 2026

Additional Comments (1)

foundation/application.go
with Start() now panicking on runner failures (line 292-294), calling it in a goroutine here means panics won't be caught by Restart(). this could crash the application unexpectedly instead of returning an error from Restart()

	startErr := make(chan error, 1)
	go func() {
		defer func() {
			if r := recover(); r != nil {
				startErr <- fmt.Errorf("panic during start: %v", r)
			}
		}()
		r.Start()
	}()
Prompt To Fix With AI
This is a comment left during a code review.
Path: foundation/application.go
Line: 214:214

Comment:
with `Start()` now panicking on runner failures (line 292-294), calling it in a goroutine here means panics won't be caught by `Restart()`. this could crash the application unexpectedly instead of returning an error from `Restart()`

```suggestion
	startErr := make(chan error, 1)
	go func() {
		defer func() {
			if r := recover(); r != nil {
				startErr <- fmt.Errorf("panic during start: %v", r)
			}
		}()
		r.Start()
	}()
```

How can I resolve this? If you propose a fix, please make it concise.

@codecov
Copy link

codecov bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (v1.17.x@c067c6d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
foundation/application.go 71.42% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v1.17.x    #1371   +/-   ##
==========================================
  Coverage           ?   68.57%           
==========================================
  Files              ?      281           
  Lines              ?    17750           
  Branches           ?        0           
==========================================
  Hits               ?    12172           
  Misses             ?     5075           
  Partials           ?      503           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl merged commit b7e5b39 into v1.17.x Feb 7, 2026
13 checks passed
@hwbrzzl hwbrzzl deleted the bowen/optimize-start branch February 7, 2026 03:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants