Code Monkey home page Code Monkey logo

Comments (8)

parroty avatar parroty commented on July 24, 2024

Thanks for the extensive report and analysis, the 3 points you mentioned makes sense. Is there any ways you can try (or provide sample code?). If you can provide PR, that would be great too, though.

from exvcr.

myronmarston avatar myronmarston commented on July 24, 2024

I tried extracting something isolated and failed, sadly, so there's something going on I don't understand and I can't really provide you with our entire codebase. I'll keep an eye out to see if it happens again and can extract something at that time.

from exvcr.

nicocharlery avatar nicocharlery commented on July 24, 2024

Hi there,

@myronmarston Have you found a workaround to this issue ?

On my project, it's happening when I have a GenServer handle_call or handle_cast spawning a process that will have to to an HTTP request to HTTPoison, faked by ExVCR. And same as @myronmarston it's happening randomly.

For now, I do a try catch on that error to having it removed to the tests. But that's not a solution :

    spawn(fn ->
      try do
        function_using_http_poison
      rescue
        e in HTTPoison.Error ->
          nil
      end

from exvcr.

myronmarston avatar myronmarston commented on July 24, 2024

@myronmarston Have you found a workaround to this issue ?

Nope.

from exvcr.

Ch4s3 avatar Ch4s3 commented on July 24, 2024

I'm having the same problem when using HTTPoison.

from exvcr.

manjufy avatar manjufy commented on July 24, 2024

Something similar to #53 it happens when we have multiple requests in the test suite. Using HTTPoison and same issue.

from exvcr.

sescobb27 avatar sescobb27 commented on July 24, 2024

i have a similar issue with parallel requests being made #127 (sorry i just found this issue), i think both are related. i also added a minimum code sample of what i'm doing.

from exvcr.

RyanSept avatar RyanSept commented on July 24, 2024

It seems that network calls from spawned processes are not mocked at all. Upon switching off my wifi and running this test when a cassette is already populated, I receive an error which indicates the cassette was ignored and that it tried to make a network request.

The behaviour was the same even after turning on the global_mock config

defmodule Api.SomeTest.Test do
  use ExUnit.Case, async: false
  use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney

  test "can get" do
    parent_pid = self()

    use_cassette "get_example_dotcom" do
      Process.spawn(
        fn ->
          res = HTTPoison.get("https://example.com")
          send(parent_pid, res)
        end,
        [:link]
      )
    end

    assert_receive {:ok, %{status_code: 200}}, 5000
  end
end
  1) test can get (Api.SomeTest.Test)
     test/api/get_example_test.exs:5
     Assertion failed, no matching message after 5000ms
     Showing 1 of 1 message in the mailbox
     code: assert_receive {:ok, %{status_code: 200}}
     mailbox:
       pattern: {:ok, %{status_code: 200}}
       value:   {:error, %HTTPoison.Error{__exception__: true, id: nil, reason: :nxdomain}}
     stacktrace:
       test/api/get_example_test.exs:18: (test)


Finished in 5.1 seconds (0.00s async, 5.1s sync)
1 test, 1 failure

from exvcr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.