Skip to content

Commit

Permalink
make WalletExtensionContainer non blocking
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Dec 27, 2023
1 parent c990832 commit 811324a
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions tools/walletextension/container/walletextension_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,29 @@ func NewWalletExtensionContainer(
}
}

// TODO Start should not be a locking process
// Start starts the wallet extension container
func (w *WalletExtensionContainer) Start() error {
httpErrChan := w.httpServer.Start()
wsErrChan := w.wsServer.Start()

select {
case err := <-httpErrChan:
if !errors.Is(err, http.ErrServerClosed) {
panic(err)
// Start a goroutine for handling HTTP server errors
go func() {
for err := range httpErrChan {
if !errors.Is(err, http.ErrServerClosed) {
w.logger.Error("HTTP server error: %v", err)
}
}
case err := <-wsErrChan:
if !errors.Is(err, http.ErrServerClosed) {
panic(err)
}()

// Start a goroutine for handling WebSocket server errors
go func() {
for err := range wsErrChan {
if !errors.Is(err, http.ErrServerClosed) {
w.logger.Error("WebSocket server error: %v", err)
}
}
}
}()

return nil
}

Expand Down

0 comments on commit 811324a

Please sign in to comment.