Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic recovery #97

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sekulicd
Copy link
Contributor

@sekulicd sekulicd commented Aug 30, 2024

Noticed in ocean bellow error that caused server crash:

panic: runtime error: index out of range [0] with length 0
2024-08-30T08:00:18.975021059Z 
goroutine 204 [running]:
github.com/vulpemventures/ocean/internal/core/application.(*TransactionService).GetTransactionInfo(0xc000209780, {0x126cab0, 0xc0020342a0}, {0xc00226b140, 0x40})
/home/runner/work/ocean/ocean/internal/core/application/transaction_service.go:93 +0xec
github.com/vulpemventures/ocean/internal/interfaces/grpc/handler.(*transaction).GetTransaction(0xc00018e678, {0x126cab0, 0xc0020342a0}, 0xe61a00?)
/home/runner/work/ocean/ocean/internal/interfaces/grpc/handler/transaction.go:31 +0x178
github.com/vulpemventures/ocean/api-spec/protobuf/gen/go/ocean/v1._TransactionService_GetTransaction_Handler.func1({0x126cab0?, 0xc0020342a0?}, {0xf2f300?, 0xc000189380?})
/home/runner/work/ocean/ocean/api-spec/protobuf/gen/go/ocean/v1/transaction_grpc.pb.go:356 +0xcb
github.com/vulpemventures/ocean/internal/interfaces/grpc/interceptor.unaryLogger({0x126cab0, 0xc0020342a0}, {0xf2f300, 0xc000189380}, 0x18?, 0xc0020f3ce0)
/home/runner/work/ocean/ocean/internal/interfaces/grpc/interceptor/logger.go:17 +0xa9
github.com/vulpemventures/ocean/internal/interfaces/grpc.(*service).start.UnaryInterceptor.ChainUnaryServer.func2.1.1({0x126cab0?, 0xc0020342a0?}, {0xf2f300?, 0xc000189380?})
/home/runner/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/chain.go:25 +0x34
github.com/vulpemventures/ocean/internal/interfaces/grpc.(*service).start.UnaryInterceptor.ChainUnaryServer.func2({0x126cab0, 0xc0020342a0}, {0xf2f300, 0xc000189380}, 0x416525?, 0x70?)
/home/runner/go/pkg/mod/github.com/grpc-ecosystem/[email protected]/chain.go:34 +0xb8
github.com/vulpemventures/ocean/api-spec/protobuf/gen/go/ocean/v1._TransactionService_GetTransaction_Handler({0xfbaa40, 0xc00018e678}, {0x126cab0, 0xc0020342a0}, 0xc00225f960, 0xc0003b6d20)
/home/runner/work/ocean/ocean/api-spec/protobuf/gen/go/ocean/v1/transaction_grpc.pb.go:358 +0x143
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003b45a0, {0x1272320, 0xc0002fb520}, 0xc000219320, 0xc0003b7710, 0x1909360, 0x0)
/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1336 +0xd16
google.golang.org/grpc.(*Server).handleStream(0xc0003b45a0, {0x1272320, 0xc0002fb520}, 0xc000219320, 0x0)
/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:1704 +0x9da
google.golang.org/grpc.(*Server).serveStreams.func1.2()
/home/runner/go/pkg/mod/google.golang.org/[email protected]/server.go:965 +0x8d
created by google.golang.org/grpc.(*Server).serveStreams.func1 in goroutine 93

This adds panic recovery interceptor and it adds check in GetTransactionInfo that prevents:
panic: runtime error: index out of range [0] with length 0

@tiero @altafan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant