Skip to content

Commit 71b1912

Browse files
committed
fix: preserve sync:stop event emission for noWatch mode
Address review feedback from @zerbitx: the initial fix disabled RestartOnError for noWatch which also prevented sync:stop from being emitted. Add an else branch that registers a lighter goroutine for noWatch mode that: - Emits the sync:stop hook when context is cancelled or sync completes - Does NOT call parent.Kill(nil) (to avoid breaking SSH injection) This preserves the sync:stop lifecycle event while still fixing the original bug where context cancellation killed the parent tomb.
1 parent dbf7b52 commit 71b1912

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

pkg/devspace/services/sync/controller.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,21 @@ func (c *controller) startWithWait(ctx devspacecontext.Context, options *Options
226226
}
227227
return nil
228228
})
229+
} else {
230+
// For noWatch syncs: emit sync:stop when context is cancelled or sync
231+
// completes, but do NOT kill the parent tomb (to avoid breaking SSH).
232+
parent.Go(func() error {
233+
select {
234+
case <-ctx.Context().Done():
235+
case <-onDone:
236+
}
237+
client.Stop(nil)
238+
hook.LogExecuteHooks(ctx.WithLogger(options.SyncLog), map[string]interface{}{
239+
"sync_config": options.SyncConfig,
240+
}, hook.EventsForSingle("stop:sync", options.Name).With("sync.stop")...)
241+
ctx.Log().Debugf("Stopped sync %s", options.SyncConfig.Path)
242+
return nil
243+
})
229244
}
230245

231246
return nil

0 commit comments

Comments
 (0)