quantum-elixir / quantum-core

:watch: Cron-like job scheduler for Elixir
https://hexdocs.pm/quantum/
Apache License 2.0
2.31k stars 148 forks source link

An exception after 2nd run of mix test in row #600

Closed Kitton closed 7 months ago

Kitton commented 7 months ago

Hello, after upgrading to version 3.5.1 we started to have this issue after running 2 times in the row mix test. mix clean in between fixes the issue but it's kind of inconvenient

    ** (EXIT) an exception was raised:
        ** (Protocol.UndefinedError) protocol String.Chars not implemented for #Reference<0.2321102968.2692218881.74074> of type Reference. This protocol is implemented for the following type(s): Atom, BitString, Date, DateTime, Decimal, Float, Floki.Selector, Floki.Selector.AttributeSelector, Floki.Selector.Combinator, Floki.Selector.Functional, Floki.Selector.PseudoClass, Integer, List, MyXQL.Queries, MyXQL.Query, MyXQL.TextQueries, MyXQL.TextQuery, NaiveDateTime, Phoenix.LiveComponent.CID, Postgrex.Copy, Postgrex.Query, Time, URI, Version, Version.Requirement
            (elixir 1.16.1) lib/string/chars.ex:3: String.Chars.impl_for!/1
            (elixir 1.16.1) lib/string/chars.ex:22: String.Chars.to_string/1
            (quantum 3.5.1) lib/quantum.ex:330: anonymous fn/3 in Quantum.remove_invalid_jobs/2
            (elixir 1.16.1) lib/enum.ex:2528: Enum."-reduce/3-lists^foldl/2-0-"/3
            (quantum 3.5.1) lib/quantum.ex:319: Quantum.remove_invalid_jobs/2
            (elixir 1.16.1) lib/keyword.ex:1149: Keyword.update_guarded/4
            (elixir 1.16.1) lib/keyword.ex:1153: Keyword.update_guarded/4
            (quantum 3.5.1) lib/quantum.ex:306: Quantum.scheduler_config/3

From the backtrace looks related to https://github.com/quantum-elixir/quantum-core/pull/523

erlang 26.2 elixir 1.16.1

Kitton commented 7 months ago

we found the reason for this - when the job doesnt have a name, but still not clear how it's related to the 3.5.1 upgrade and why this happens

gives an error in our case 👇

config :app, App.Scheduler,
  jobs: [
    {"*/15 * * * *", {Mix.Tasks.Task1, :run, [nil]}}

works fine 👇

config :app, App.Scheduler,
  jobs: [
    task_1: [
      schedule: "*/15 * * * *",
      task:  fn -> Mix.Tasks.Task1.run(nil) end
    ]
  ]
Brianvdb commented 7 months ago

After upgrading to 3.5.1 we are also getting that exception when starting our application.

We just rolled it back to 3.5.0

maennchen commented 7 months ago

I see the issue. I‘ll do a fix and new release.

maennchen commented 7 months ago

Released as v3.5.2