Skip to content

Commit

Permalink
fix(plugin): do not panic at the EOF error
Browse files Browse the repository at this point in the history
Currently we panic when the io reader when
it is returned an error. We should accept a io.EOF
error, so this patch is fixing the following crash

running 2 tests
panic: EOF

goroutine 1 [running]:
github.com/vincenzopalazzo/cln4go/plugin.(*Plugin[...]).Start(0x575a60)
	/home/vincent/github/work/ocean/cln-offers/vendor/github.com/vincenzopalazzo/cln4go/plugin/plugin.go:200 +0x696
main.main()
	/home/vincent/github/work/ocean/cln-offers/cmd/plugin.go:17 +0x291

Signed-off-by: Vincenzo Palazzo <[email protected]>
  • Loading branch information
vincenzopalazzo committed Feb 29, 2024
1 parent fa830ce commit 7ff032d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package plugin
import (
"bufio"
"fmt"
"io"
"os"

"github.com/vincenzopalazzo/cln4go/comm/encoder"
Expand Down Expand Up @@ -197,6 +198,9 @@ func (self *Plugin[T]) Start() {
bytesResp1, err := reader.Read(recvData[:])

if err != nil {
if err == io.EOF {
break
}
panic(err)
}
rawRequest = append(rawRequest, recvData[:bytesResp1]...)
Expand Down

0 comments on commit 7ff032d

Please sign in to comment.