tallarium/reverse_proxy_plug

[TEST] The client adapter does not support streaming responses. Please use :buffer response mode.

Closed this issue · 9 comments

I'm receiving the error during tests:
The client adapter does not support streaming responses. Please use :buffer response mode.

But I don't understand how to specify that streaming mode is supported.

Config:
config :reverse_proxy_plug, :http_client, ReverseProxyPlug.HTTPClient.Adapters.HTTPoison

Elixir version: 1.16.1

It will be detected automatically - it is whether or not stream_response/1 exists in the module, essentially.

To eliminate some possibilities:

  • do you have httpoison installed as a dependency?
  • do you have any :client options supplied to individual ReverseProxyPlug lines in the router?

It will be detected automatically - it is whether or not stream_response/1 exists in the module, essentially.

To eliminate some possibilities:

  • do you have httpoison installed as a dependency?
  • do you have any :client options supplied to individual ReverseProxyPlug lines in the router?

Hi thank you for the response!

  • Yes httpoison is installed with latest version: 2.2.1
  • No any other option added:
    forward("/url", MyApp.Plug.UrlProxy)

we are just using forward with no any other opts

This is also happening to us in our development instances after bumping to 2.4. We have HTTPoison 2.2.1. I also tried with Tesla, but not luck.

// config.exs
config :reverse_proxy_plug, :http_client, ReverseProxyPlug.HTTPClient.Adapters.HTTPoison
// router.ex
get "/*path", ReverseProxyPlug, upstream: ....

@mwhitworth any news on that?

@mwhitworth any news on that?

I'm waiting for appropriate access to fix and override some CI issues, as I've left the Tallarium organization.

Once that happens (the contact is away on leave), I'll address this as soon as possible.

@mwhitworth any news on that?

I'm waiting for appropriate access to fix and override some CI issues, as I've left the Tallarium organization.

Once that happens (the contact is away on leave), I'll address this as soon as possible.

No problem, thank you very much

According to our observation, the problem lies here:

not is_nil(client) ->
Keyword.put(opts, :client, client)
Code.ensure_loaded?(HTTPClient.Adapters.HTTPoison) and is_nil(client) ->
Keyword.put(opts, :client, HTTPClient.Adapters.HTTPoison)

If you have :http_client config set, it results in the first branch. However, since this branch does not involve dynamic code loading, it can cause crash (at subsequent ensure_response_mode_compatibility/1 check) after module unloading happened somewhere else in your development process. For instance, auto-recompiling using exsync.

If :http_client config is NOT set, it results in the second branch (fallback to Adapters.HTTPoison) where it always calls Code.ensure_loaded?/1, thus the module is always loaded before ensure_response_mode_compatibility/1 check.

So interestingly, "NOT" setting :http_client config in your config.exs can be temporary workaround.

According to our observation, the problem lies here:

not is_nil(client) ->
Keyword.put(opts, :client, client)
Code.ensure_loaded?(HTTPClient.Adapters.HTTPoison) and is_nil(client) ->
Keyword.put(opts, :client, HTTPClient.Adapters.HTTPoison)

If you have :http_client config set, it results in the first branch. However, since this branch does not involve dynamic code loading, it can cause crash (at subsequent ensure_response_mode_compatibility/1 check) after module unloading happened somewhere else in your development process. For instance, auto-recompiling using exsync.

If :http_client config is NOT set, it results in the second branch (fallback to Adapters.HTTPoison) where it always calls Code.ensure_loaded?/1, thus the module is always loaded before ensure_response_mode_compatibility/1 check.

So interestingly, "NOT" setting :http_client config in your config.exs can be temporary workaround.

Yeah in that way it works 🤯

A fix for this, which uses Code.ensure_loaded to ensure that the module has been loaded, is in v2.4.1.

Thank you @ymtszw for investigating this, identifying the root cause, and providing a workaround.