-
Notifications
You must be signed in to change notification settings - Fork 20.1k
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
Graphql: How to cancel a graphql query for protect DOS attack? #26026
Comments
This can be implemented by adding a context with timeout here: go-ethereum/graphql/service.go Lines 43 to 46 in a2b7481
ctx, cancel = context.WithTimeout(r.Context(), 60 * time.Second)
defer cancel()
response := h.Schema.Exec(ctx, params.Query, params.OperationName, params.Variables) |
@orangeagain You indicated you're willing to implement this feature. Can you please open a PR with the above solution? |
I have no expirence on golang, and I am planning make a standalone graphql server by c# |
Fixed by #26116 |
Rationale
Why should this feature exist?
Hackers could construct a huge query to block the service,We need to abort this query after it has taken a lot of time
What are the use-cases?
Both front-end, back-end and data analysts need graphql public services
Implementation
Do you have ideas regarding the implementation of this feature?
maybe use cancelable greenthread to limit task execution time and count cpu cost
Are you willing to implement this feature?
yes
The text was updated successfully, but these errors were encountered: