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

Conversation

mitchellhenke
Copy link
Contributor

I've had some pretty bad crashes from this (bringing down the entire verk application), and the root cause is from System.stracktrace here returning a stacktrace like {GenServer, :call, [:my_named_process, \"1\", 5000]}.

Verk eventually attempts to format with Exception.format_stacktrace/1 here, which doesn't work since that calls Enum.map_join, and a tuple isn't Enumerable.

A contrived example of a worker that causes this:

defmodule Verk.TestWorker do
  def perform(key_or_keys) do
    GenServer.call(:my_named_process, "1")
  end
end

I added a test that will fail without my changes:

  1) test call retry on a job with non-enum stacktrace (Verk.QueueManagerTest)
     test/queue_manager_test.exs:213
     ** (Protocol.UndefinedError) protocol Enumerable not implemented for {GenServer, :call, [:process, "1"]}
     stacktrace:
       (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
       (elixir) lib/enum.ex:116: Enumerable.reduce/3
       (elixir) lib/enum.ex:1486: Enum.reduce/3
       (elixir) lib/enum.ex:1118: Enum.map_join/3
       (elixir) lib/exception.ex:388: Exception.format_stacktrace/1
       (verk) lib/verk/queue_manager.ex:134: Verk.QueueManager.build_retry_job/5
       (verk) lib/verk/queue_manager.ex:122: Verk.QueueManager.handle_call/3
       test/queue_manager_test.exs:224

Beyond it's impact on verk here, I'm not sure if it's considered an Elixir issue that System.stacktrace may return something not necessarily formattable.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 81.948% when pulling a71e18d on mitchellhenke:fix-bad-stacktrace-formatting into 7ee6e4d on edgurgel:master.

@edgurgel
Copy link
Owner

edgurgel commented May 4, 2016

I think we need to review how Elixir deal with stacktraces with ExUnit as they probably need to somehow make the stacktrace readable.

But this is awesome start as people won't have Verk restarting because of this. Thanks for the PR.

@edgurgel edgurgel merged commit 60772d0 into edgurgel:master May 4, 2016
@edgurgel
Copy link
Owner

edgurgel commented May 4, 2016

I'm keen to release a new version this weekend. Thanks again for such great feedback and contributions 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants