From 87da81ffebd9b57e364c1e20d4858be2af5531b0 Mon Sep 17 00:00:00 2001 From: Virgil Date: Sat, 4 Apr 2026 02:14:58 +0000 Subject: [PATCH] fix(process): leave exit action errors unset --- actions.go | 2 +- service.go | 6 +++--- service_test.go | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/actions.go b/actions.go index 8a2526d..f4ab6d1 100644 --- a/actions.go +++ b/actions.go @@ -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. diff --git a/service.go b/service.go index c0d3c6b..5458d1c 100644 --- a/service.go +++ b/service.go @@ -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 { diff --git a/service_test.go b/service_test.go index 6579bdf..518106b 100644 --- a/service_test.go +++ b/service_test.go @@ -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) }) }