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

Add TODO for Finch v0.20 #437

Merged
merged 1 commit into from
Nov 25, 2024
Merged

Conversation

jonatanklosko
Copy link
Contributor

Just to be sure :D

@wojtekmach wojtekmach merged commit a9d713a into wojtekmach:main Nov 25, 2024
2 checks passed
@wojtekmach
Copy link
Owner

Thanks!

@wojtekmach
Copy link
Owner

@jonatanklosko I changed this TODO to another TODO: 520bdfe. :) I tested it with:

Mix.install([
  {:req, github: "wojtekmach/req"},
  {:finch, github: "sneako/finch", override: true},
  :bandit
])

pid = self()

spawn(fn ->
  {:ok, _} =
    Bandit.start_link(
      plug: fn conn, _ ->
        conn = Plug.Conn.send_chunked(conn, 200)
        {:ok, conn} = Plug.Conn.chunk(conn, "foo")
        raise "oops"
        conn
      end,
      port: 8080
    )

  send(pid, :ready)
  Process.sleep(:infinity)
end)

receive do
  :ready -> :ok
end

dbg(Req.get!("http://localhost:8080", retry: false, into: []))

and it seems to work but lmk if something doesn't look right.

I'm ready for next Req release, lmk if you'd like to add something before I publish it.

@jonatanklosko
Copy link
Contributor Author

If the error happens before :status, or on a different status, then we never create the collector. So the new clause should be this:

{:error, exception, {acc, _req, _resp}} ->
  with {acc, collector} <- acc do
    collector.(acc, :halt)
  end

  {req, normalize_error(exception)}

or maybe two separate clauses:

{:error, exception, {nil, _req, _resp}} ->
  {req, normalize_error(exception)}

{:error, exception, {acc, _req, _resp}} ->
  collector.(acc, :halt)
  {req, normalize_error(exception)}

@jonatanklosko jonatanklosko deleted the jk-todo branch November 25, 2024 12:06
@wojtekmach
Copy link
Owner

I went with two clauses, thanks!

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.

2 participants