Comments (8)
I am getting the similar error:
** (exit) exited in: :gen_server.call(#PID<0.695.0>, :close)
** (EXIT) an exception was raised:
** (FunctionClauseError) no function clause matching in ExVCR.Adapter.Hackney.apply_filters/1
lib/exvcr/adapter/hackney.ex:54: ExVCR.Adapter.Hackney.apply_filters({:ok, #Reference<0.0.7.51>})
lib/exvcr/handler.ex:136: ExVCR.Handler.get_response_from_server/2
(hackney) :hackney.request(:get, "http://myappserver/service/events", [{"Content-Type", "application/json"}, {"Accept", "text/event-stream"}], "", [:async, {:stream_to, #PID<0.696.0>}, {:recv_timeout, :infinity}])
(httpoison) lib/httpoison/base.ex:402: HTTPoison.Base.request/9
(myapp_streamer) lib/myapp_streamer/conn.ex:49: MyAppStreamer.Connection.connect/2
lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
stacktrace:
(stdlib) gen_server.erl:204: :gen_server.call/2```
from exvcr.
Tried with both ExVCR 0.7 and 0.8.4 and issue still persists..
from exvcr.
I investigated a little bit more and I found:
https://github.com/erlang/otp/blob/maint/lib/inets/src/http_client/httpc.erl#L139
%% Description: Sends a HTTP-request. The function can be both
%% syncronus and asynchronous in the later case the function will
%% return {ok, RequestId} and later on a message will be sent to the
%% calling process on the format {http, {RequestId, {StatusLine,
%% Headers, Body}}} or {http, {RequestId, {error, Reason}}}
from exvcr.
I was able to narrow the use case, this fails:
defmodule TwitterReqTest do
use ExUnit.Case, async: false
use ExVCR.Mock, adapter: ExVCR.Adapter.Httpc
doctest TwitterReq
test "example test" do
use_cassette "example httpc" do
:httpc.request(:get, {'http://www.twitter.com', []}, [], [{:sync, false}, {:stream, :self}])
# NOTE: This will never be reached currently
receive do
everything -> IO.inspect everything
after
10_000 -> IO.inspect "timeout!"
end
end
end
end
And the exception is:
$ MIX_ENV=test mix vcr.delete --all; mix test
Deleted example_httpc.json.
1) test example test (TwitterReqTest)
test/twitter_req_test.exs:6
** (FunctionClauseError) no function clause matching in ExVCR.Adapter.Httpc.apply_filters/1
stacktrace:
lib/exvcr/adapter/httpc.ex:56: ExVCR.Adapter.Httpc.apply_filters({:ok, #Reference<0.0.3.49>})
lib/exvcr/handler.ex:136: ExVCR.Handler.get_response_from_server/2
(inets) :httpc.request(:get, {'http://www.twitter.com', []}, [], [sync: false, stream: :self])
test/twitter_req_test.exs:8: (test)
Finished in 0.2 seconds
1 test, 1 failure
Then I did a dumb change on exvcr
to consume in apply_filters
the stream and it records correctly, however it does not replay. Will investigate more. Hope that @parroty could help us! thanks :)
from exvcr.
Thanks for the report and investigation (sorry not being responding).
The current ExVCR.Adapter.Httpc
hasn't been able to parse the stream response. When [sync: false, stream: :self]
is specified for :httpc.request
, it returns the id reference to the stream, instead of response body, then ExVCR is failing to parse the result.
The id reference is as recorded in the error message like {:ok, #Reference<0.0.3.49>}
.
It's one of the reason that tests for ExTwitter stream API (which uses httpc.request
) is not using exvcr and doing some tricky mocking as follows.
I'm wondering what would be the good way to mock this type of request response. It may require special treatment and also it becomes different for each adapters.
One quick approach might be to do simple mock response like as in the above extwitter_stream_test.exs
though.
from exvcr.
@parroty do you have any plans to implement this or is there some way I can help? I'm running into the same problem.
from exvcr.
@rupurt if it's useful you could grab some initial prototyping work from here #85
Unluckily, I have no time in these days and I don't have that use case to cover anymore. Feel free!
from exvcr.
@kpanic no worries. Thanks for the initial library. It's been very useful :)
from exvcr.
Related Issues (20)
- ignore tzdata HOT 2
- Problem with ExJsx dependency HOT 10
- Request was made? HOT 1
- ExVCR.IEx not working with adapter: ExVCR.Adapter.Hackney HOT 2
- disable global mock HOT 14
- Global Mock does not use cassettes with HTTPoison HOT 2
- How to use ExVCR with Finch? HOT 3
- Filter sensitive data after all request made HOT 1
- Support `mix vcr.check --include mytag` ?
- Can't match json response bodies for removing sensitive data? HOT 1
- Cassettes are not injected after test cases! HOT 1
- ** (ArgumentError) argument error
- Support for Finch 0.9.x? HOT 1
- Feature request: `start_cassette` and `stop_cassette`
- Same as vcr request: save response json body with more formatting HOT 1
- Generated custom_cassettes with patchfile HOT 1
- Wrong responses when HTTPoison is used from async Task HOT 4
- Async tests using Bypass interfere with ExVcr tests HOT 3
- support httpoison 2.0 HOT 1
- Version `0.14.0` cannot be compiled in projects not using `Finch`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exvcr.