Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion robot/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ func (svc *webService) stopWeb() {
if svc.cancelFunc != nil {
svc.cancelFunc()
}
svc.closeStreamServer()
svc.isRunning = false
svc.webWorkers.Wait()
}
Expand Down Expand Up @@ -484,7 +485,6 @@ func (svc *webService) runWeb(ctx context.Context, options weboptions.Options) (
svc.logger.Errorw("error stopping rpc server", "error", err)
}
}()
svc.closeStreamServer()
})
svc.webWorkers.Add(1)
utils.PanicCapturingGo(func() {
Expand Down
19 changes: 11 additions & 8 deletions robot/web/web_c.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@ func (svc *webService) Reconfigure(ctx context.Context, _ resource.Dependencies,
}

func (svc *webService) closeStreamServer() {
if err := svc.streamServer.Close(); err != nil {
svc.logger.Errorw("error closing stream server", "error", err)
}
// streamServer is called by svc.stopWeb, which is called by both Stop and Close in the shutdown process.
if svc.streamServer != nil {
if err := svc.streamServer.Close(); err != nil {
svc.logger.Errorw("error closing stream server", "error", err)
}

// RSDK-10570: Nil out the stream server such that we recreate it on a `runWeb` call. Recreating
// the stream server is important for passing in a fresh `svc.cancelCtx` that's in an alive
// state. The stream server checks that context, for example, when handling the AddStream API
// call.
svc.streamServer = nil
// RSDK-10570: Nil out the stream server such that we recreate it on a `runWeb` call. Recreating
// the stream server is important for passing in a fresh `svc.cancelCtx` that's in an alive
// state. The stream server checks that context, for example, when handling the AddStream API
// call.
svc.streamServer = nil
}
}

func (svc *webService) initStreamServer(ctx context.Context, srv rpc.Server) error {
Expand Down
Loading