Skip to content

Commit 5a1d3f8

Browse files
authored
Fix CLI hanging with certain commands (#1730)
1 parent 67a5162 commit 5a1d3f8

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

cmd/flow/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
package main
2121

2222
import (
23+
"syscall"
24+
2325
"github.com/spf13/cobra"
2426

2527
"github.com/onflow/flow-cli/internal/accounts"
@@ -129,4 +131,10 @@ func main() {
129131
if err := cmd.Execute(); err != nil {
130132
util.Exit(1, err.Error())
131133
}
134+
135+
// We are using a syscall because there is some dependency related to
136+
// connecting to the network that is not being closed properly. This
137+
// issue appeared with Go 1.23.1, but was not present in Go 1.22.
138+
// It looks like this may be GRPC related from the stack trace.
139+
syscall.Exit(command.StatusCode)
132140
}

internal/command/command.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ const (
8989
logLevelNone = "none"
9090
)
9191

92+
var StatusCode = 0
93+
9294
// AddToParent add new command to main parent cmd
9395
// and initializes all necessary things as well as take care of errors and output
9496
// here we can do all boilerplate code that is else copied in each command and make sure
@@ -171,7 +173,8 @@ func (c Command) AddToParent(parent *cobra.Command) {
171173
if res, ok := result.(ResultWithExitCode); ok {
172174
exitCode = res.ExitCode()
173175
}
174-
os.Exit(exitCode)
176+
177+
StatusCode = exitCode
175178
}
176179

177180
bindFlags(c)

0 commit comments

Comments
 (0)