fix(process): leave exit action errors unset

This commit is contained in:
Virgil 2026-04-04 02:14:58 +00:00
parent 26af69d87b
commit 87da81ffeb
3 changed files with 7 additions and 6 deletions

View file

@ -84,7 +84,7 @@ type ActionProcessExited struct {
ID string
ExitCode int
Duration time.Duration
Error error // Non-nil if failed to start or was killed
Error error // Reserved for future exit metadata; currently left unset by the service
}
// ActionProcessKilled is broadcast when a process is terminated.

View file

@ -224,7 +224,7 @@ func (s *Service) StartWithOptions(ctx context.Context, opts RunOptions) (*Proce
ID: id,
ExitCode: -1,
Duration: time.Since(startedAt),
Error: coreerr.E("Service.StartWithOptions", "failed to start process", err),
Error: nil,
})
}
return nil, coreerr.E("Service.StartWithOptions", "failed to start process", err)
@ -283,7 +283,7 @@ func (s *Service) StartWithOptions(ctx context.Context, opts RunOptions) (*Proce
err := cmd.Wait()
duration := time.Since(proc.StartedAt)
status, exitCode, exitErr, signalName := classifyProcessExit(err)
status, exitCode, _, signalName := classifyProcessExit(err)
proc.mu.Lock()
proc.Duration = duration
@ -301,7 +301,7 @@ func (s *Service) StartWithOptions(ctx context.Context, opts RunOptions) (*Proce
ID: id,
ExitCode: exitCode,
Duration: duration,
Error: exitErr,
Error: nil,
}
if c := s.coreApp(); c != nil {

View file

@ -274,6 +274,7 @@ func TestService_Actions(t *testing.T) {
assert.Len(t, exited, 1)
assert.Equal(t, 0, exited[0].ExitCode)
assert.Nil(t, exited[0].Error)
})
t.Run("broadcasts killed events", func(t *testing.T) {
@ -326,7 +327,7 @@ func TestService_Actions(t *testing.T) {
defer mu.Unlock()
assert.Len(t, exited, 1)
assert.Equal(t, proc.ID, exited[0].ID)
assert.Error(t, exited[0].Error)
assert.Nil(t, exited[0].Error)
assert.Equal(t, StatusKilled, proc.Status)
})
@ -359,7 +360,7 @@ func TestService_Actions(t *testing.T) {
defer mu.Unlock()
require.Len(t, exited, 1)
assert.Equal(t, -1, exited[0].ExitCode)
assert.Error(t, exited[0].Error)
assert.Nil(t, exited[0].Error)
})
}