Skip to content

Ferrum::Network::Response#loaded? fails on 302 redirects after #309 #321

@dmorgan-fa

Description

@dmorgan-fa

Hi,
Firstly, thanks for the excellent work on this gem and Cuprite!

We've been looking into some reliability issues lately and trying different things. One thing that I've noticed, is a recent change:

now causes redirect requests to be considered still pending even though they've completed:

Ferrum::TimeoutError:
         Timed out waiting for response. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the :timeout option to a higher value might help.
         Connections still pending:
          {:status=>302, :status_text=>"Found", :url=>"http://practice1.lvh.me:9888/practice_dashboard/companies/895397944/notes/1"}
Full Ferrum::Network::Exchange object here
#<Ferrum::Network::Exchange
  @id="E711BF6D793E1D3EC660F87242702CEF"
  @intercepted_request=#<Ferrum::Network::InterceptedRequest
    @request_id="interception-job-32.1"
    @frame_id="E80A9391E528438362D111598AAB1C2B"
    @resource_type="Document"
    @request={
      "url"=>"http://subdomain000001.lvh.me:9887/overview",
      "method"=>"GET",
      "headers"=>{
        "Accept"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
        "Cookie"=>"[REDACTED]",
        "Referer"=>"http://subdomain000001.lvh.me:9887/",
        "Upgrade-Insecure-Requests"=>"1",
        "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.124 Safari/537.36"
      },
      "initialPriority"=>"VeryHigh",
      "referrerPolicy"=>"origin"
    }
  >
  @request= #<Ferrum::Network::Request:0x000000011c7e0b90
    @params={
      "requestId"=>"E711BF6D793E1D3EC660F87242702CEF",
      "loaderId"=>"E711BF6D793E1D3EC660F87242702CEF",
      "documentURL"=>"http://subdomain000001.lvh.me:9887/overview",
      "request"=>{
        "url"=>"http://subdomain000001.lvh.me:9887/overview",
        "method"=>"GET",
        "headers"=>{
          "Content-Type"=>"application/x-www-form-urlencoded",
          "Origin"=>"http://subdomain000001.lvh.me:9887",
          "Referer"=>"http://subdomain000001.lvh.me:9887/",
          "Upgrade-Insecure-Requests"=>"1",
          "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.124 Safari/537.36"
        },
        "mixedContentType"=>"none",
        "initialPriority"=>"VeryHigh",
        "referrerPolicy"=>"origin",
        "isSameSite"=>true
      },
      "timestamp"=>122384.896241,
      "wallTime"=>1671721817.864675,
      "initiator"=>{
        "type"=>"other"
      },
      "redirectHasExtraInfo"=>true,
      "redirectResponse"=>{
        "url"=>"http://subdomain000001.lvh.me:9887/sessions",
        "status"=>302,
        "statusText"=>"Found",
        "headers"=>{
          "Cache-Control"=>"no-store",
          "Content-Length"=>"206",
          "Content-Type"=>"text/html; charset=utf-8",
          "Feature-Policy"=>"accelerometer 'none'; autoplay 'none'; ambient-light-sensor 'none'; camera 'none'; encrypted-media 'none'; fullscreen 'self'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; speaker 'none'; usb 'none'; vibrate 'none'; vr 'none'",
          "Location"=>"http://subdomain000001.lvh.me:9887/overview",
          "Pragma"=>"no-cache",
          "X-Frame-Options"=>"SAMEORIGIN",
          "X-Host"=>"mac",
          "X-Request-Id"=>"7fe4438c-e2da-4846-b9e1-57bbfa40344d",
          "X-Rev"=>"2aad5e7960c77fe0e405880b0974b0cda2c3a57c",
          "X-Runtime"=>"0.373335",
          "X-XSS-Protection"=>"1; mode=block"
        },
        "mimeType"=>"text/html",
        "connectionReused"=>true,
        "connectionId"=>36,
        "remoteIPAddress"=>"127.0.0.1",
        "remotePort"=>9887,
        "fromDiskCache"=>false,
        "fromServiceWorker"=>false,
        "fromPrefetchCache"=>false,
        "encodedDataLength"=>1630,
        "timing"=>{
          "requestTime"=>122384.433822,
          "proxyStart"=>-1,
          "proxyEnd"=>-1,
          "dnsStart"=>-1,
          "dnsEnd"=>-1,
          "connectStart"=>-1,
          "connectEnd"=>-1,
          "sslStart"=>-1,
          "sslEnd"=>-1,
          "workerStart"=>-1,
          "workerReady"=>-1,
          "workerFetchStart"=>-1,
          "workerRespondWithSettled"=>-1,
          "sendStart"=>0.197,
          "sendEnd"=>0.256,
          "pushStart"=>0,
          "pushEnd"=>0,
          "receiveHeadersEnd"=>461.364
        },
        "responseTime"=>1671721817863.499,
        "protocol"=>"http/1.1",
        "alternateProtocolUsage"=>"unspecifiedReason",
        "securityState"=>"insecure"
      },
      "type"=>"Document",
      "frameId"=>"E80A9391E528438362D111598AAB1C2B",
      "hasUserGesture"=>true
    },
    @request={
      "url"=>"http://subdomain000001.lvh.me:9887/overview",
      "method"=>"GET",
      "headers"=>{
        "Content-Type"=>"application/x-www-form-urlencoded",
        "Origin"=>"http://subdomain000001.lvh.me:9887",
        "Referer"=>"http://subdomain000001.lvh.me:9887/",
        "Upgrade-Insecure-Requests"=>"1",
        "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/108.0.5359.124 Safari/537.36"
      },
      "mixedContentType"=>"none",
      "initialPriority"=>"VeryHigh",
      "referrerPolicy"=>"origin",
      "isSameSite"=>true
    }
  >
  @response= #<Ferrum::Network::Response
    @params={
      "requestId"=>"E711BF6D793E1D3EC660F87242702CEF",
      "loaderId"=>"E711BF6D793E1D3EC660F87242702CEF",
      "documentURL"=>"http://subdomain000001.lvh.me:9887/setup",
      "request"=>{
        "url"=>"http://subdomain000001.lvh.me:9887/setup",
        "method"=>"GET",
        "headers"=>{"Content-Type"=>"application/x-www-form-urlencoded",
        "Origin"=>"http://subdomain000001.lvh.me:9887",
        "Referer"=>"http://subdomain000001.lvh.me:9887/",
        "Upgrade-Insecure-Requests"=>"1",
        "User-Agent"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML,like Gecko) HeadlessChrome/108.0.5359.124 Safari/537.36"},
        "mixedContentType"=>"none",
        "initialPriority"=>"VeryHigh",
        "referrerPolicy"=>"origin",
        "isSameSite"=>true
      },
      "timestamp"=>122385.173023,
      "wallTime"=>1671721818.141461,
      "initiator"=>{
        "type"=>"other"
      },
      "redirectHasExtraInfo"=>true,
      "redirectResponse"=>{
        "url"=>"http://subdomain000001.lvh.me:9887/overview",
        "status"=>302,
        "statusText"=>"Found",
        "headers"=>{
          "Cache-Control"=>"no-store",
          "Content-Length"=>"203",
          "Content-Type"=>"text/html; charset=utf-8",
          "Feature-Policy"=>"accelerometer 'none'; autoplay 'none'; ambient-light-sensor 'none'; camera 'none'; encrypted-media 'none'; fullscreen 'self'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; speaker 'none'; usb 'none'; vibrate 'none'; vr 'none'",
          "Location"=>"http://subdomain000001.lvh.me:9887/setup",
          "Pragma"=>"no-cache",
          "X-Frame-Options"=>"SAMEORIGIN",
          "X-Host"=>"mac",
          "X-Request-Id"=>"fc59edb4-4158-48bc-b64e-761dc432ef25",
          "X-Rev"=>"2aad5e7960c77fe0e405880b0974b0cda2c3a57c",
          "X-Runtime"=>"0.189034",
          "X-XSS-Protection"=>"1; mode=block"
        },
        "mimeType"=>"text/html",
        "connectionReused"=>true,
        "connectionId"=>36,
        "remoteIPAddress"=>"127.0.0.1",
        "remotePort"=>9887,
        "fromDiskCache"=>false,
        "fromServiceWorker"=>false,
        "fromPrefetchCache"=>false,
        "encodedDataLength"=>1761,
        "timing"=>{
          "requestTime"=>122384.896961,
          "proxyStart"=>-1,
          "proxyEnd"=>-1,
          "dnsStart"=>-1,
          "dnsEnd"=>-1,
          "connectStart"=>-1,
          "connectEnd"=>-1,
          "sslStart"=>-1,
          "sslEnd"=>-1,
          "workerStart"=>-1,
          "workerReady"=>-1,
          "workerFetchStart"=>-1,
          "workerRespondWithSettled"=>-1,
          "sendStart"=>0.146,
          "sendEnd"=>0.185,
          "pushStart"=>0,
          "pushEnd"=>0,
          "receiveHeadersEnd"=>275.388
        },
        "responseTime"=>1671721818140.693,
        "protocol"=>"http/1.1",
        "alternateProtocolUsage"=>"unspecifiedReason",
        "securityState"=>"insecure"
      },
      "type"=>"Document",
      "frameId"=>"E80A9391E528438362D111598AAB1C2B",
      "hasUserGesture"=>true
    }
    @response={
      "url"=>"http://subdomain000001.lvh.me:9887/overview",
      "status"=>302,
      "statusText"=>"Found",
      "headers"=>{
        "Cache-Control"=>"no-store",
        "Content-Length"=>"203",
        "Content-Type"=>"text/html; charset=utf-8",
        "Feature-Policy"=>"accelerometer 'none'; autoplay 'none'; ambient-light-sensor 'none'; camera 'none'; encrypted-media 'none'; fullscreen 'self'; geolocation 'none'; gyroscope 'none'; magnetometer 'none'; microphone 'none'; midi 'none'; payment 'none'; picture-in-picture 'none'; speaker 'none'; usb 'none'; vibrate 'none'; vr 'none'",
        "Location"=>"http://subdomain000001.lvh.me:9887/setup",
        "Pragma"=>"no-cache",
        "X-Frame-Options"=>"SAMEORIGIN",
        "X-Host"=>"mac",
        "X-Request-Id"=>"fc59edb4-4158-48bc-b64e-761dc432ef25",
        "X-Rev"=>"2aad5e7960c77fe0e405880b0974b0cda2c3a57c",
        "X-Runtime"=>"0.189034",
        "X-XSS-Protection"=>"1; mode=block"
      },
      "mimeType"=>"text/html",
      "connectionReused"=>true,
      "connectionId"=>36,
      "remoteIPAddress"=>"127.0.0.1",
      "remotePort"=>9887,
      "fromDiskCache"=>false,
      "fromServiceWorker"=>false,
      "fromPrefetchCache"=>false,
      "encodedDataLength"=>1761,
      "timing"=>{
        "requestTime"=>122384.896961,
        "proxyStart"=>-1,
        "proxyEnd"=>-1,
        "dnsStart"=>-1,
        "dnsEnd"=>-1,
        "connectStart"=>-1,
        "connectEnd"=>-1,
        "sslStart"=>-1,
        "sslEnd"=>-1,
        "workerStart"=>-1,
        "workerReady"=>-1,
        "workerFetchStart"=>-1,
        "workerRespondWithSettled"=>-1,
        "sendStart"=>0.146,
        "sendEnd"=>0.185,
        "pushStart"=>0,
        "pushEnd"=>0,
        "receiveHeadersEnd"=>275.388
      },
      "responseTime"=>1671721818140.693,
      "protocol"=>"http/1.1",
      "alternateProtocolUsage"=>"unspecifiedReason",
      "securityState"=>"insecure"
    }
  >
  @error=nil
>

This output was from a forked branch with some extra logging:

Admittedly this is only seen when we're calling Cuprite's wait_for_network_idle directly within a spec (something we're looking to remove), but it looks like something that will trip Ferrum up if wait_for_idle gets called and there's been a redirect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions