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

Do not rely directly on the ranch #147

Closed

Conversation

fishtreesugar
Copy link

bypass only utilizes a small part of the ranch API; we could simply use :gen_tcp directly.

And this changes might lower the dependency footprint when bypass going to support different HTTP server: #144

@IceDragon200
Copy link

I would suggest running:

mix deps.clean --unlock --unused

To remove ranch from the mix.lock file as well.

@fishtreesugar
Copy link
Author

I would suggest running:

mix deps.clean --unlock --unused

To remove ranch from the mix.lock file as well.

ranch remains an indirect dependency of bypass since it relies on plug_cowboy.

`bypass` only utilizes a small part of the `ranch` API; we could simply use `:gen_tcp` directly.

And this changes might lower the dependency footprint when `bypass` going to support different HTTP server: PSPDFKit-labs#144
@fishtreesugar
Copy link
Author

Hi @bszaf, I found #134 have merged. WDYT of this PR?

@IceDragon200
Copy link

IceDragon200 commented Oct 20, 2024

I tested the code, unfortunately ranch 2 will break this, since Bypass passes the socket it creates to the cowboy server, but ranch 2 doesn't allow that anymore requiring a refactor.

So even though you've removed the explicit calls, ranch is still a problem.

EDIT:

     ** (RuntimeError) Failed to start bypass instance.
     Reason: bad child specification, got: {{:badmatch, {:error, {:bad_option, :socket}}}, [{Bypass.Instance, :do_up, 2, [file: ~c"lib/bypass/instance.ex", line: 330]}, {Bypass.Instance, :init,
1, [file: ~c"lib/bypass/instance.ex", line: 37]}, {:gen_server, :init_it, 2, [file: ~c"gen_server.erl", line: 2229]}, {:gen_server, :init_it, 6, [file: ~c"gen_server.erl", line: 2184]}, {:proc_lib, :init_p_do_apply, 3, [file: ~c"proc_lib.erl", line: 329]}]}

To test just add {:ranch, "~> 2.1", override: true}, to the deps (or in this case, putting it back just to force ranch 2)

@fishtreesugar
Copy link
Author

Thank you for the testing. Just take a look of ranch 2.0 migration guide:

The socket option was removed. A more viable solution is to define a custom transport module that returns a fresh socket when Transport:listen/1 is called.

It seems that a complete rewrite is necessary if bypass is to support Ranch 2.0+

@fishtreesugar fishtreesugar deleted the no-ranch-directly branch October 20, 2024 06:47
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