scrapli / scrapligo

scrapli, but in go!
MIT License
244 stars 35 forks source link

EOF is not propagated to SendInputB #164

Closed gescheit closed 7 months ago

gescheit commented 7 months ago

If a device closes connection during execution, Channel.read() just silently suppress EOF. It is defined here: https://github.com/scrapli/scrapligo/blob/31a4363eecf3e34ea4e44149cc5a90419f4d3171/channel/read.go#L55 introduced in PR https://github.com/scrapli/scrapligo/pull/109. In this way SendInputB() will wait for command timeout. Not only it is pointless waiting but also it hides real result. For example, if it is reboot command then receiving errTimeoutError is unclear whether the command was executed successfully or not. I think it should be like this:

            if errors.Is(err, io.EOF) {
                // the underlying transport was closed so just return
                c.Errs <- err
                return
            }

or

            c.l.Criticalf(
                "encountered error reading from transport during channel read loop. error: %s", err,
            )

            c.Errs <- err
            if errors.Is(err, io.EOF) {
                return
            }
carlmontanari commented 7 months ago

hey @gescheit seems reasonable to me -- are you up for a pr for this?