Skip to content

Compiling umbrella siblings with and without optional dependencies leads to inconsistent apps #15445

@tomekowal

Description

@tomekowal

Existing issue

  • I have searched existing issues and could not find a duplicate.

Elixir and Erlang/OTP versions

I got this while trying to update to Elixir 1.20

[os_mon] cpu supervisor port (cpu_sup): Erlang has closed
[os_mon] memory supervisor port (memsup): Erlang has closed
common_deps/shared_telemetry
** (EXIT from #PID<0.95.0>) an exception was raised:
    ** (RuntimeError) found error while checking types for Tesla.Adapter.Finch.stream/3:

** (RuntimeError) expected Finch.Response to return struct metadata, but got none
The exception happened while checking this code:

defp stream(req, name, opts) do
  owner = :erlang.self()
  ref = :erlang.make_ref()

  fun = fn
    {:status, status}, _acc -> status
    {:headers, headers}, status -> :erlang.send(owner, {ref, {:status, status, headers}})
    {:data, data}, _acc -> :erlang.send(owner, {ref, {:data, data}})
    {:trailers, trailers}, _acc -> trailers
    {:error, error}, _acc -> :erlang.send(owner, {ref, {:error, error}})
    {:error, error, _}, _acc -> :erlang.send(owner, {ref, {:error, error}})
  end

  task =
    Task.async(fn ->
      handle_stream_response(Finch.stream(req, name, nil, fun, opts), ref, owner)
    end)

  receive do
    {^ref, {:status, status, headers}} ->
      body =
        Stream.unfold(nil, fn _ ->
          receive do
            {^ref, {:data, data}} ->
              {data, nil}

            {^ref, :eof} ->
              Task.await(task)
              nil

            {^ref, {:error, _error}} ->
              Task.shutdown(task, :brutal_kill)
              nil
          after
            opts[:receive_timeout] ->
              Task.shutdown(task, :brutal_kill)
              nil
          end
        end)

      {:ok, %Finch.Response{trailers: [], status: status, headers: headers, body: body}}

    {^ref, {:error, error}} ->
      Task.shutdown(task, :brutal_kill)
      {:error, error}
  after
    opts[:receive_timeout] ->
      Task.shutdown(task, :brutal_kill)
      {:error, :timeout}
  end
end

Please report this bug at: [https://github.com/elixir-lang/elixir/issues](https://github.com/elixir-lang/elixir/issues?q=sort%3Aupdated-desc+is%3Aissue+state%3Aopen+)

        (elixir 1.20.0) lib/module/types/of.ex:473: Module.Types.Of.struct_instance/7
        (elixir 1.20.0) lib/module/types/expr.ex:747: Module.Types.Expr.of_tuple/7
        (elixir 1.20.0) lib/module/types/expr.ex:972: anonymous fn/7 in Module.Types.Expr.of_clauses/7
        (elixir 1.20.0) lib/module/types/expr.ex:992: anonymous fn/8 in Module.Types.Expr.of_clauses_fun/7
        (elixir 1.20.0) lib/enum.ex:2622: Enum."-reduce/3-lists^foldl/2-0-"/3
        (elixir 1.20.0) lib/module/types/expr.ex:983: Module.Types.Expr.of_clauses_fun/7
        (elixir 1.20.0) lib/enum.ex:2622: Enum."-reduce/3-lists^foldl/2-0-"/3
        (elixir 1.20.0) lib/module/types/expr.ex:572: anonymous fn/5 in Module.Types.Expr.of_expr/5

Let me know if you need som kind of reproduction, but it seems the error message already produces one.

Operating system

Linux Ubuntu

Current behavior

It errors, explicitely asking to open a bug here.

Expected behavior

If it is a typing violation, it should be reported.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions