go-imap icon indicating copy to clipboard operation
go-imap copied to clipboard

Deadlock on client.go:284 in unknown response?

Open qb-0 opened this issue 5 years ago • 0 comments

In my case there is a server which disallow imap clients if it isn't activated. Anyway, is there a way to recover from client.go:284 (execute)?

Code:

func main() {
    c, err := client.DialWithDialerTLS(&net.Dialer{Timeout: time.Second * time.Duration(10)}, "imap.poczta.fm:993", &tls.Config{InsecureSkipVerify: true})
    c.SetDebug(os.Stdout)

    if err != nil {
        panic(err)
    }
    if err = c.Login("x", "x"); err != nil {
        panic(err)
    }
    mBox, err := c.Select("INBOX", true)
    if err != nil {
        panic(err)
    }

    // Won't be executed
    fmt.Println(mBox.Unseen)
    fmt.Println("* Done")
}

Debug:

LAaN9Q LOGIN "x" "x"
LAaN9Q OK [ALERT] Please enable IMAP access in your account settings first.
T4dxhg EXAMINE INBOX
* BAD [ALERT] Please enable IMAP access in your account settings first.

Delve:

(dlv) grs
  Goroutine 1 - User: /go/src/github.com/emersion/go-imap/client/client.go:284 github.com/emersion/go-imap/client.(*Client).execute (0x6d643b)

(dlv) gr 1 frame 2 list
Goroutine 1 frame 2 at /go/src/github.com/emersion/go-imap/client/client.go:284 (PC: 0x6d643b)
   279:				return nil, err
   280:			}
   281:		}
   282:	
   283:		for {
=> 284:			select {
   285:			case reply := <-replies:
   286:				// Response handler needs to send a reply (Used for AUTHENTICATE)
   287:				if err := c.writeReply(reply); err != nil {
   288:					close(unregister)
   289:					return nil, err

qb-0 avatar Dec 07 '19 13:12 qb-0