PSPDFKit-labs / bypass

Bypass provides a quick way to create a custom plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests.
https://hex.pm/packages/bypass
MIT License
964 stars 111 forks source link

Cowboy plug has changed again #68

Closed nathany closed 5 years ago

nathany commented 5 years ago

The release of plug 1.7.0 (which is required for Phoenix 1.4 rc.2) now uses plug_cowboy and there no longer is a Plug.Adapters.Cowboy2.

At minimum, the Bypass README needs updating, but I'm also seeing a number of deprecation warnings and some failed tests in our project related to Bypass (0.9.0).

hez commented 5 years ago

I am getting errors starting my tests with bypass in them now.

    ** (ArgumentError) argument error
     stacktrace:
       :erlang.apply({:error, {{:badmatch, {:error, {{:shutdown, {:failed_to_start_child, :ranch_acceptors_sup, :badarg}}, {:child, :undefined, {:ranch_listener_sup, #Reference<0.1061947866.316932098.194467>}, {:ranch_listener_sup, :start_link, [#Reference<0.1061947866.316932098.194467>, :ranch_tcp, %{connection_type: :supervisor, max_connections: 16384, num_acceptors: 5, socket_opts: [port: 52030, socket: #Port<0.1463>]}, :cowboy_clear, %{connection_type: :supervisor, env: %{dispatch: [{:_, [], [{:_, [], Plug.Cowboy.Handler, {Bypass.Plug, #PID<0.848.0>}}]}]}, stream_handlers: [Plug.Cowboy.Stream]}]}, :permanent, :infinity, :supervisor, [:ranch_listener_sup]}}}}, [{Bypass.Instance, :do_up, 3, [file: 'lib/bypass/instance.ex', line: 271]}, {Bypass.Instance, :init, 1, [file: 'lib/bypass/instance.ex', line: 37]}, {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]}, {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 342]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}}, :port, [])
AndrewDryga commented 5 years ago

We are getting this error:

** (ArgumentError) argument error
     code: bypass = Bypass.open() |> bypass_facebook_graph_api()
     stacktrace:
       :erlang.apply({:error, "plug_cowboy dependency missing"}, :port, [])
eaguilera23 commented 5 years ago

I'm also having problems using Phoenix 1.4 rc.3. It doesn't start the process:

{:error,
 {{:badmatch,
   {:error,
    {{:shutdown, {:failed_to_start_child, :ranch_acceptors_sup, :badarg}},
     {:child, :undefined,
      {:ranch_listener_sup, #Reference<0.1966561138.2964586498.61828>},
      {:ranch_listener_sup, :start_link,
       [
         #Reference<0.1966561138.2964586498.61828>,
         :ranch_tcp,
         %{
           connection_type: :supervisor,
           max_connections: 16384,
           num_acceptors: 5,
           socket_opts: [port: 54928, socket: #Port<0.72>]
         },
         :cowboy_clear,
         %{
           connection_type: :supervisor,
           env: %{
             dispatch: [
               {:_, [],
                [{:_, [], Plug.Cowboy.Handler, {Bypass.Plug, #PID<0.867.0>}}]}
             ]
           },
           stream_handlers: [Plug.Cowboy.Stream]
         }
       ]}, :permanent, :infinity, :supervisor, [:ranch_listener_sup]}}}},
  [
    {Bypass.Instance, :do_up, 3, [file: 'lib/bypass/instance.ex', line: 271]},
    {Bypass.Instance, :init, 1, [file: 'lib/bypass/instance.ex', line: 37]},
    {:gen_server, :init_it, 2, [file: 'gen_server.erl', line: 374]},
    {:gen_server, :init_it, 6, [file: 'gen_server.erl', line: 342]},
    {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}
  ]}}

Plus a lot of warnings.

EDIT: I do have the plug_cowboy dependency

eaguilera23 commented 5 years ago

This has been fixed in #67 and #69. If you could merge them would be awesome @MSch

fbjork commented 5 years ago

@MSch Now that Phoenix 1.4 is out it would be great to see a 1.0.0 version released that is compatible with Cowboy 2.x plug.

MSch commented 5 years ago

First off, thanks everyone for bringing this up and the PRs! I'm going to release a new version once #71 is through.

MSch commented 5 years ago

1.0 is out.