Skip to content
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

Fix bad stacktrace formatting #61

Merged
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
5 changes: 4 additions & 1 deletion lib/verk/queue_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ defmodule Verk.QueueManager do
end

defp build_retry_job(job, retry_count, failed_at, exception, stacktrace) do
job = %{job | error_backtrace: Exception.format_stacktrace(stacktrace),
job = %{job | error_backtrace: format_stacktrace(stacktrace),
error_message: Exception.message(exception),
retry_count: retry_count}
if retry_count > 1 do
Expand All @@ -155,4 +155,7 @@ defmodule Verk.QueueManager do
defp inprogress(queue_name, node_id) do
"inprogress:#{queue_name}:#{node_id}"
end

defp format_stacktrace(stacktrace) when is_list(stacktrace), do: Exception.format_stacktrace(stacktrace)
defp format_stacktrace(stacktrace), do: inspect(stacktrace)
end
16 changes: 16 additions & 0 deletions test/queue_manager_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,20 @@ defmodule Verk.QueueManagerTest do

assert validate DeadSet
end

test "call retry on a job with non-enum stacktrace" do
failed_at = 100

stacktrace = {GenServer, :call, [:process, "1"]}
job = %Job{ retry_count: 1, failed_at: failed_at, error_backtrace: inspect(stacktrace), error_message: "reasons" }
expect(RetrySet, :add!, [job, failed_at, :redis], "payload")

state = %State{ redis: :redis }
job = %Job{ retry_count: 0 }
exception = RuntimeError.exception("reasons")

assert handle_call({ :retry, job, failed_at, exception, stacktrace}, :from, state) == { :reply, :ok, state }

assert validate RetrySet
end
end