Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
ee9ff064
Unverified
Commit
ee9ff064
authored
Nov 08, 2022
by
Ahmet Avci
Committed by
GitHub
Nov 08, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
graphql: add query timeout (#26116)
This PR adds a 60 second timeout to graphql queries.
parent
91397343
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletion
+6
-1
service.go
graphql/service.go
+6
-1
No files found.
graphql/service.go
View file @
ee9ff064
...
@@ -17,8 +17,10 @@
...
@@ -17,8 +17,10 @@
package
graphql
package
graphql
import
(
import
(
"context"
"encoding/json"
"encoding/json"
"net/http"
"net/http"
"time"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/eth/filters"
"github.com/ethereum/go-ethereum/internal/ethapi"
"github.com/ethereum/go-ethereum/internal/ethapi"
...
@@ -41,7 +43,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
...
@@ -41,7 +43,10 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
return
}
}
response
:=
h
.
Schema
.
Exec
(
r
.
Context
(),
params
.
Query
,
params
.
OperationName
,
params
.
Variables
)
ctx
,
cancel
:=
context
.
WithTimeout
(
r
.
Context
(),
60
*
time
.
Second
)
defer
cancel
()
response
:=
h
.
Schema
.
Exec
(
ctx
,
params
.
Query
,
params
.
OperationName
,
params
.
Variables
)
responseJSON
,
err
:=
json
.
Marshal
(
response
)
responseJSON
,
err
:=
json
.
Marshal
(
response
)
if
err
!=
nil
{
if
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment