Skip to content
代码片段 群组 项目
提交 cf2a96c1 编辑于 作者: Alexandru Croitor's avatar Alexandru Croitor
浏览文件

Merge branch 'cablett-graphql-handle-timeout' into 'master'

GraphQL: More informative timeout message

See merge request gitlab-org/gitlab!90319
No related branches found
No related tags found
无相关合并请求
...@@ -82,6 +82,13 @@ def execute ...@@ -82,6 +82,13 @@ def execute
render_error(exception.message, status: :unprocessable_entity) render_error(exception.message, status: :unprocessable_entity)
end end
rescue_from ActiveRecord::QueryAborted do |exception|
log_exception(exception)
error = "Request timed out. Please try a less complex query or a smaller set of records."
render_error(error, status: :service_unavailable)
end
override :feature_category override :feature_category
def feature_category def feature_category
::Gitlab::FeatureCategories.default.from_request(request) || super ::Gitlab::FeatureCategories.default.from_request(request) || super
......
...@@ -27,6 +27,18 @@ ...@@ -27,6 +27,18 @@
) )
end end
it 'handles a timeout nicely' do
allow(subject).to receive(:execute) do
raise ActiveRecord::QueryCanceled, '**taps wristwatch**'
end
post :execute
expect(json_response).to include(
'errors' => include(a_hash_including('message' => /Request timed out/))
)
end
it 'handles StandardError' do it 'handles StandardError' do
allow(subject).to receive(:execute) do allow(subject).to receive(:execute) do
raise StandardError, message raise StandardError, message
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册