{"action":"created","issue":{"url":"https://api.github.com/repos/lostisland/faraday/issues/408","labels_url":"https://api.github.com/repos/lostisland/faraday/issues/408/labels{/name}","comments_url":"https://api.github.com/repos/lostisland/faraday/issues/408/comments","events_url":"https://api.github.com/repos/lostisland/faraday/issues/408/events","html_url":"https://github.com/lostisland/faraday/issues/408","id":42152685,"number":408,"title":"typhoeus parallel middleware processing broken in 0.9","user":{"login":"nevans","id":6142,"avatar_url":"https://avatars.githubusercontent.com/u/6142?v=3","gravatar_id":"","url":"https://api.github.com/users/nevans","html_url":"https://github.com/nevans","followers_url":"https://api.github.com/users/nevans/followers","following_url":"https://api.github.com/users/nevans/following{/other_user}","gists_url":"https://api.github.com/users/nevans/gists{/gist_id}","starred_url":"https://api.github.com/users/nevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevans/subscriptions","organizations_url":"https://api.github.com/users/nevans/orgs","repos_url":"https://api.github.com/users/nevans/repos","events_url":"https://api.github.com/users/nevans/events{/privacy}","received_events_url":"https://api.github.com/users/nevans/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2014-09-07T21:23:52Z","updated_at":"2015-09-21T20:25:56Z","closed_at":null,"body":"I know that the typhoeus adapter is part of the typhoeus gem, but I'm trying to debug this and it looks like faraday must have changed something about how it handles middleware for parallel requests.  In particular, I can see that the middleware *is* running on parallel requests, but the resulting env[:body] seems to be getting lost or thrown away at some point.\r\n\r\ntest.rb:\r\n```` ruby\r\nrequire \"typhoeus\"\r\nrequire \"typhoeus/adapters/faraday\"\r\nrequire \"faraday_middleware\"\r\n\r\nclass DebugMiddleware < Faraday::Middleware\r\n  def initialize(app, name)\r\n    super(app)\r\n    @name = name\r\n  end\r\n  def call(env0)\r\n    @app.call(env0).on_complete do |env1|\r\n      $stderr.puts \"Debug %s: %p\" % [@name, env1[:body]]\r\n    end\r\n  end\r\nend\r\n\r\nconn = Faraday.new(url: \"http://echo.jsontest.com/\") do |faraday|\r\n  faraday.use      DebugMiddleware, \"after JSON parse \"\r\n  faraday.response :json\r\n  faraday.use      DebugMiddleware, \"before JSON parse\"\r\n  faraday.adapter  :typhoeus\r\nend\r\n\r\nr0 = conn.get(\"/foo/bar/baz/quux\")\r\nputs \"Final value r0         : %p\" % [r0.body]\r\nputs\r\n\r\nr1, r2 = nil\r\nconn.in_parallel do\r\n  r1 = conn.get(\"/foo/bar/key/value\")\r\n  r2 = conn.get(\"/blah/blah/one/two\")\r\nend\r\nputs \"Final value r1         : %p\" % [r1.body]\r\nputs \"Final value r2         : %p\" % [r2.body]\r\n````\r\n\r\nWith faraday 0.8.9, faraday_middleware 0.8.8, and typhoeus 0.6.8:\r\n````\r\n$ bundle exec ruby test.rb \r\nDebug before JSON parse: \"{\\n   \\\"baz\\\": \\\"quux\\\",\\n   \\\"foo\\\": \\\"bar\\\"\\n}\\n\"\r\nDebug after JSON parse : {\"baz\"=>\"quux\", \"foo\"=>\"bar\"}\r\nFinal value r0         : {\"baz\"=>\"quux\", \"foo\"=>\"bar\"}\r\n\r\nDebug before JSON parse: \"{\\n   \\\"foo\\\": \\\"bar\\\",\\n   \\\"key\\\": \\\"value\\\"\\n}\\n\"\r\nDebug after JSON parse : {\"foo\"=>\"bar\", \"key\"=>\"value\"}\r\nDebug before JSON parse: \"{\\n   \\\"one\\\": \\\"two\\\",\\n   \\\"blah\\\": \\\"blah\\\"\\n}\\n\"\r\nDebug after JSON parse : {\"one\"=>\"two\", \"blah\"=>\"blah\"}\r\nFinal value r1         : {\"foo\"=>\"bar\", \"key\"=>\"value\"}\r\nFinal value r2         : {\"one\"=>\"two\", \"blah\"=>\"blah\"}\r\n````\r\n\r\nWith faraday 0.9.0, faraday_middleware 0.9.1, and typhoeus 0.6.8:\r\n````\r\n $ bundle exec ruby test.rb              \r\nDebug before JSON parse: \"{\\n   \\\"baz\\\": \\\"quux\\\",\\n   \\\"foo\\\": \\\"bar\\\"\\n}\\n\"\r\nDebug after JSON parse : {\"baz\"=>\"quux\", \"foo\"=>\"bar\"}\r\nFinal value r0         : {\"baz\"=>\"quux\", \"foo\"=>\"bar\"}\r\n\r\nDebug before JSON parse: \"{\\n   \\\"foo\\\": \\\"bar\\\",\\n   \\\"key\\\": \\\"value\\\"\\n}\\n\"\r\nDebug after JSON parse : {\"foo\"=>\"bar\", \"key\"=>\"value\"}\r\nDebug before JSON parse: \"{\\n   \\\"one\\\": \\\"two\\\",\\n   \\\"blah\\\": \\\"blah\\\"\\n}\\n\"\r\nDebug after JSON parse : {\"one\"=>\"two\", \"blah\"=>\"blah\"}\r\nFinal value r1         : \"{\\n   \\\"foo\\\": \\\"bar\\\",\\n   \\\"key\\\": \\\"value\\\"\\n}\\n\"\r\nFinal value r2         : \"{\\n   \\\"one\\\": \\\"two\\\",\\n   \\\"blah\\\": \\\"blah\\\"\\n}\\n\"\r\n````"},"comment":{"url":"https://api.github.com/repos/lostisland/faraday/issues/comments/142098949","html_url":"https://github.com/lostisland/faraday/issues/408#issuecomment-142098949","issue_url":"https://api.github.com/repos/lostisland/faraday/issues/408","id":142098949,"user":{"login":"nevans","id":6142,"avatar_url":"https://avatars.githubusercontent.com/u/6142?v=3","gravatar_id":"","url":"https://api.github.com/users/nevans","html_url":"https://github.com/nevans","followers_url":"https://api.github.com/users/nevans/followers","following_url":"https://api.github.com/users/nevans/following{/other_user}","gists_url":"https://api.github.com/users/nevans/gists{/gist_id}","starred_url":"https://api.github.com/users/nevans/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nevans/subscriptions","organizations_url":"https://api.github.com/users/nevans/orgs","repos_url":"https://api.github.com/users/nevans/repos","events_url":"https://api.github.com/users/nevans/events{/privacy}","received_events_url":"https://api.github.com/users/nevans/received_events","type":"User","site_admin":false},"created_at":"2015-09-21T20:25:56Z","updated_at":"2015-09-21T20:25:56Z","body":"I finally tried to pull out my monkeypatch with 0.9.1 and discovered that edacd5eb57ea13accab3097649690ae5f48f421a does not fix all of my issues.  In particular, if an adapter or middleware wants to create any `custom_members` on `env`, they will be lost.  I'll put together a pull request with some tests shortly."}}