Skip to content

Truncate error backtrace when saving failed executions #260

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

Merged
merged 1 commit into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/models/solid_queue/failed_execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ def retry
end

private
BACKTRACE_LINES_LIMIT = 400

def expand_error_details_from_exception
if exception
self.error = { exception_class: exception.class.name, message: exception.message, backtrace: exception.backtrace }
self.error = { exception_class: exception.class.name, message: exception.message, backtrace: exception.backtrace.first(BACKTRACE_LINES_LIMIT) }
end
end
end
Expand Down
20 changes: 20 additions & 0 deletions test/dummy/app/jobs/infinite_recursion_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class InfiniteRecursionJob < ApplicationJob
queue_as :background

def perform
start
end

private
def start
continue
end

def continue
start_again
end

def start_again
start
end
end
8 changes: 8 additions & 0 deletions test/models/solid_queue/failed_execution_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ class SolidQueue::FailedExecutionTest < ActiveSupport::TestCase
assert SolidQueue::Job.last.failed?
end

test "run job that fails with a SystemStackError (stack level too deep)" do
InfiniteRecursionJob.perform_later
@worker.start

assert_equal 1, SolidQueue::FailedExecution.count
assert SolidQueue::Job.last.failed?
end

test "retry failed job" do
RaisingJob.perform_later(RuntimeError, "A")
@worker.start
Expand Down
Loading