saucelabs/forwarder

race condition on proxy close results in closing channel twice

Closed this issue · 1 comments

2023/09/13 11:29:18 [proxy] [INFO] no upstream proxy specified
2023/09/13 11:29:18 [proxy] [INFO] localhost proxying mode=deny
2023/09/13 11:29:18 [api] [INFO] HTTP server listen address=127.0.0.1:10000 protocol=http
^C2023/09/13 11:29:33 [proxy] [DEBUG] listener closed, returning
2023/09/13 11:29:33 [api] [DEBUG] server was shutdown gracefully
2023/09/13 11:29:33 [proxy] [INFO] closing down proxy
2023/09/13 11:29:33 [proxy] [INFO] closing down proxy
2023/09/13 11:29:33 [proxy] [INFO] waiting for connections to close
2023/09/13 11:29:33 [proxy] [INFO] all connections closed
panic: close of closed channel

goroutine 1 [running]:
github.com/saucelabs/forwarder/internal/martian.(*Proxy).Close(0x140001fa180)
        forwarder/internal/martian/proxy.go:200 +0x54
github.com/saucelabs/forwarder.(*HTTPProxy).Close(0x140002ae820)
        forwarder/http_proxy.go:583 +0x60
github.com/saucelabs/forwarder/cmd/forwarder/run.(*command).runE(0x140001d9080, 0x140002a8300, {0x0?, 0x0?, 0x0?})
        forwarder/cmd/forwarder/run/run.go:170 +0xe34
github.com/spf13/cobra.(*Command).execute(0x140002a8300, {0x14000202fc0, 0x6, 0x6})
        go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:916 +0x658
github.com/spf13/cobra.(*Command).ExecuteC(0x140002a8000)
        go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:1040 +0x318
github.com/spf13/cobra.(*Command).Execute(...)
        go/pkg/mod/github.com/spf13/cobra@v1.6.0/command.go:968
main.main()
        forwarder/cmd/forwarder/main.go:14 +0x20
exit status 2

Needs a lock.