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

batch_cache sort_by_created_asc/1 anonymous fn/3 #79

Open
fantypants opened this issue Nov 26, 2021 · 4 comments
Open

batch_cache sort_by_created_asc/1 anonymous fn/3 #79

fantypants opened this issue Nov 26, 2021 · 4 comments

Comments

@fantypants
Copy link
Contributor

batch_cache:44 returns

:gen_event handler LogflareLogger.HttpBackend installed in Logger terminating
** (exit) an exception was raised:
    ** (BadFunctionError) expected a function, got: :asc
        (elixir) lib/enum.ex:2354: anonymous fn/3 in Enum.sort_by/3
        (stdlib) lists.erl:969: :lists.sort/2
        (elixir) lib/enum.ex:2354: Enum.sort_by/3
        (logflare_logger_backend) lib/logflare_logger/batch_cache.ex:44: LogflareLogger.BatchCache.flush/1
        (logflare_logger_backend) lib/logflare_logger/http_backend.ex:147: LogflareLogger.HttpBackend.flush!/1
        (stdlib) gen_event.erl:577: :gen_event.server_update/4
        (stdlib) gen_event.erl:559: :gen_event.server_notify/4
        (stdlib) gen_event.erl:347: :gen_event.handle_msg/6
        (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

Relevant fix:
Change:
Enum.sort_by(pending_events, & &1.id, :asc)
to
Enum.sort_by(pending_events, &(&1.id), &<=/2)

@chasers
Copy link
Contributor

chasers commented Nov 26, 2021

Just curious what version of Elixir are you on?

@fantypants
Copy link
Contributor Author

Erlang/OTP 22 [erts-10.6.4] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1]

Elixir 1.9.1 (compiled with Erlang/OTP 22)

Thanks for the prompt reply!

@chasers
Copy link
Contributor

chasers commented Nov 26, 2021

Ah yeah, this is why. :asc was introduced later. But no reason we can't update this for backward compatibility.

@fantypants
Copy link
Contributor Author

Ah yeah, this is why. :asc was introduced later. But no reason we can't update this for backward compatibility.

have a suss at the PR I just submitted, let me know if there's anything we can do further to support

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

No branches or pull requests

2 participants