Skip to content

Commit 4087d8d

Browse files
authored
Merge pull request ethereum#32 from rus-alex/feature/api-deadline
API call timeout
2 parents 778b950 + f33b70b commit 4087d8d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

rpc/service.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"runtime"
2525
"strings"
2626
"sync"
27+
"time"
2728
"unicode"
2829

2930
"github.com/ethereum/go-ethereum/log"
@@ -182,6 +183,9 @@ func (c *callback) makeArgTypes() {
182183

183184
// call invokes the callback.
184185
func (c *callback) call(ctx context.Context, method string, args []reflect.Value) (res interface{}, errRes error) {
186+
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
187+
defer cancel()
188+
185189
// Create the argument slice.
186190
fullargs := make([]reflect.Value, 0, 2+len(args))
187191
if c.rcvr.IsValid() {

0 commit comments

Comments
 (0)