racket / racket-pkg-website

A frontend for the Racket Package Catalog.
Other
9 stars 15 forks source link

http-conn-sendrecv!: contract violation expected: http-conn-live? given: #<http-conn> #36

Closed SuzanneSoy closed 7 years ago

SuzanneSoy commented 7 years ago

@leafac Asked on IRC today about an error he encountered after updating the url for his package from https://git.leafac.com/pollen-component to https://git.leafac.com/pollen-component.git.

The error makes it sound like a stale HTTP connection was re-used (I'm not familiar with network programming in Racket, though).

Here's the error message:

http-conn-sendrecv!: contract violation
  expected: http-conn-live?
  given: #<http-conn>
  in: the 1st argument of
      (->*
       (http-conn-live? (or/c bytes? string?))
       (#:close?
        boolean?
        #:content-decode
        (listof symbol?)
        #:data
        (or/c
         #f
         bytes?
         string?
         (->
          (-> (or/c bytes? string?) void?)
          any))
        #:headers
        (listof (or/c bytes? string?))
        #:method
        (or/c bytes? string? symbol?)
        #:version
        (or/c bytes? string?))
       (values
        bytes?
        (listof bytes?)
        input-port?))
  contract from: 
      <collects>/net/http-client.rkt
  blaming: <collects>/net/git-checkout.rkt
   (assuming the contract is correct)
  at: <collects>/net/http-client.rkt:380.3
  context...:
   /home/pkgserver/racket/collects/racket/contract/private/blame.rkt:159:0: raise-blame-error16
   /home/pkgserver/racket/collects/racket/contract/private/arrow-val-first.rkt:400:5: mk-call
   /home/pkgserver/racket/collects/racket/contract/private/arrow-val-first.rkt:397:3
   /home/pkgserver/racket/collects/net/git-checkout.rkt:788:2: for-loop
   /home/pkgserver/racket/collects/net/git-checkout.rkt:720:0: read-dumb-objects
   /home/pkgserver/racket/collects/net/git-checkout.rkt:142:11
   /home/pkgserver/racket/collects/net/git-checkout.rkt:39:2: retry-loop
   /home/pkgserver/racket/collects/pkg/private/download.rkt:101:2: download!
   /home/pkgserver/racket/collects/pkg/private/download.rkt:93:0: download-repo!24
   /home/pkgserver/racket/collects/pkg/private/stage.rkt:299:11
   /home/pkgserver/racket/collects/pkg/private/stage.rkt:106:0: stage-package/info46
   /home/pkgserver/racket/collects/pkg/private/stage.rkt:693:0: pkg-stage62
   /home/pkgserver/racket/collects/pkg/private/content.rkt:39:0: get-pkg-content20
   /home/pkgserver/racket/collects/racket/contract/private/arrow-val-first.rkt:397:3
   /home/pkgserver/pkg-index/official/update.rkt:109:0: update-from-content
   /home/pkgserver/racket/collects/racket/private/more-scheme.rkt:261:28
   ...

Screenshot of the above error message

leafac commented 7 years ago

Here’s the link to my package with the error message: https://pkgd.racket-lang.org/pkgn/package/pollen-component

leafac commented 7 years ago

Also, if there’s anything that I can do to help diagnose or fix the issue, please let me know.

leafac commented 7 years ago

For what it’s worth, I clicked on “Rescan all my packages” and waited a few times and nothing changed.

jeapostrophe commented 7 years ago

Hi @leafac - The error is not on the package server, but in the interaction of Racket's git implementation and the git server that it looks like you are running. I can reproduce this error locally by running

raco pkg install https://git.leafac.com/pollen-component.git

I also get an error when I run

racket -l- net/git-checkout --https git.leafac.com pollen-component.git test

I'm not sure what it all means because I can't see the server logs on your end or what is going wrong. Can you look into it?

leafac commented 7 years ago

Hi @jeapostrophe,

First, thanks for looking into the issue :)

Here’s the evidence I was able to collect:

Racket

$ racket -l- net/git-checkout --https git.leafac.com pollen-component.git test
Contacting git.leafac.com
Getting refs [dumb protocol]
Server does not support `shallow`
Downloading loose objects
http-conn-sendrecv!: contract violation
  expected: http-conn-live?
  given: #<http-conn>
  in: the 1st argument of
      (->*
       (http-conn-live? (or/c bytes? string?))
       (#:close?
        boolean?
        #:content-decode
        (listof symbol?)
        #:data
        (or/c
         #f
         bytes?
         string?
         (->
          (-> (or/c bytes? string?) void?)
          any))
        #:headers
        (listof (or/c bytes? string?))
        #:method
        (or/c bytes? string? symbol?)
        #:version
        (or/c bytes? string?))
       (values
        bytes?
        (listof bytes?)
        input-port?))
  contract from: 
      <collects>/net/http-client.rkt
  blaming: <collects>/net/git-checkout.rkt
   (assuming the contract is correct)
  at: <collects>/net/http-client.rkt:453.3
  context...:
   /Applications/Racket v6.8/collects/racket/contract/private/blame.rkt:159:0: raise-blame-error16
   /Applications/Racket v6.8/collects/racket/contract/private/arrow-val-first.rkt:400:5: mk-call
   /Applications/Racket v6.8/collects/racket/contract/private/arrow-val-first.rkt:397:3
   /Applications/Racket v6.8/collects/net/git-checkout.rkt:807:2: for-loop
   /Applications/Racket v6.8/collects/net/git-checkout.rkt:739:0: read-dumb-objects
   /Applications/Racket v6.8/collects/net/git-checkout.rkt:157:11
   /Applications/Racket v6.8/collects/net/git-checkout.rkt:54:2: retry-loop
   (submod /Applications/Racket v6.8/collects/net/git-checkout.rkt main): [running body]
Cleaning up

Server logs:

128.220.159.7 - - [26/Jan/2017:18:54:13 +0000] "GET /pollen-component.git/info/refs?service=git-upload-pack HTTP/1.1" 200 127 "-" "git/1.9" "-"
128.220.159.7 - - [26/Jan/2017:18:54:13 +0000] "GET /pollen-component.git/objects/info/packs HTTP/1.1" 200 5 "-" "Racket/6.8 (net/http-client)" "-"

Git

$ git clone https://git.leafac.com/pollen-component.git
Cloning into 'pollen-component'...
Checking connectivity... done.

Server logs:

128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/info/refs?service=git-upload-pack HTTP/1.1" 200 127 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/HEAD HTTP/1.1" 200 34 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/aa/3dfae5f26bda11ee1bed633f3352797960a3f1 HTTP/1.1" 200 186 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/b1/ba1c7d8f51fefee36b93da0e6b2455057c5d76 HTTP/1.1" 200 333 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/a6/496d4d3e88f631928acf406f42bb352e8187bc HTTP/1.1" 200 172 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/91/07d3d078bfd11a2b8536d7b47d83e869b022e8 HTTP/1.1" 200 334 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/4e/f298cd8467e1ab921dea14bc64b9940706ff52 HTTP/1.1" 200 122 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/7c/492892f01062483327d343929f71b4a7e0d54b HTTP/1.1" 200 206 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/ac/59ee7998e782cd517eba3b94c580470af7888f HTTP/1.1" 200 102 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/e8/dd2b4cd527cf76ad63e5848fe204f5b43a97fe HTTP/1.1" 200 1518 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/7c/a40abcfb6cc1f4878721d19bb4c336ecc63c19 HTTP/1.1" 200 146 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/e6/2b6e5f4bb769af759f9b3d5efbb3bd63014225 HTTP/1.1" 200 460 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/69/e19770bc4fe6abea2872472f6cb70ce510146a HTTP/1.1" 200 201 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/94/a9ed024d3859793618152ea559a168bbcbb5e2 HTTP/1.1" 200 14255 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/65/4d8e6bfd4531de94b0d820f25b16c5dcf1b293 HTTP/1.1" 200 206 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/e8/213d85790e7a49278b7a2a2d9e55fd62182206 HTTP/1.1" 200 1223 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/fc/53b068c03add4fce984ff4950dba664f68aa29 HTTP/1.1" 200 333 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/80/292fb3c8cc221e940220625a7cecee6cb79e97 HTTP/1.1" 200 186 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/21/e7e3925df036d09c232dea1a106b32cedb3e11 HTTP/1.1" 200 463 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/0e/31122c529e5db51e68f573671dabee9e2b1844 HTTP/1.1" 200 5030 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/45/e4e273211e98a696244b75bec25a1565ba7253 HTTP/1.1" 200 201 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/2b/1d9991d2ee1845eee2094568455ed5052e9c79 HTTP/1.1" 200 36948 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/bb/ae1cadb4fb38607bf1199af430bd08abcc43a3 HTTP/1.1" 200 531 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/00/d701843e15307ec3d6567dad155477edcfaa66 HTTP/1.1" 200 4238 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/bd/5f082718cc2774e391f9a5965ffc7119b3729a HTTP/1.1" 200 209 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/c9/aa5c522a2f0e1e817f43e10975cc9e200c5deb HTTP/1.1" 200 173 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/58/1b19cd76e689fa808b28c92cbead44c3bfd4af HTTP/1.1" 200 174 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/91/b9ef0b0a3d168f6321666507f952b75edc14bf HTTP/1.1" 200 201 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/95/016b34159be646001cc9b894effb6f1de1f468 HTTP/1.1" 200 334 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/38/02793d78bf4917f81d85bc17ad9b60c6d6bdc3 HTTP/1.1" 200 4235 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/37/f8afbdc1a8100c6159184f70940bf5fdf1e166 HTTP/1.1" 200 96 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/50/dc45cc306480cfc1ca6b208670f9ccf834f021 HTTP/1.1" 200 130 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/0d/8bdf66457593515223d4d760b4662d0cade79f HTTP/1.1" 200 397 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/08/9889b3d420695a3e8ba25ca0881f531e276d8a HTTP/1.1" 200 127 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/d0/f583d4442ea39b5ecdc16db8c90231ce28f293 HTTP/1.1" 200 78 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/51/267532a67f70557a2b4009335a4e7fe09ccc3d HTTP/1.1" 200 89 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/02/498b0cad77c227a6125939944e2b4f780985bb HTTP/1.1" 200 287 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/ea/a8a2b51993fc6d69738e03dc36b914124e0a2f HTTP/1.1" 200 137 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/fc/6d09ca963324dcbaa497c0734009c00d2b7b2f HTTP/1.1" 200 128 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/4f/e559daa9a1b8c86596ad33268fa048f1f79b75 HTTP/1.1" 200 87 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/22/197a419d695684b3448125d91df1a0f473c6d0 HTTP/1.1" 200 115 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/b2/8ac6d5a08cf180ca40fd053ba42fa11dd0d141 HTTP/1.1" 200 94 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/e5/2921666a3558036500b6f1b0de4914070cbef0 HTTP/1.1" 200 59 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/7f/a939fe1e06ec21b2d5c053755666b6bfb052e0 HTTP/1.1" 200 4237 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/77/b6a66dfac8684d316ae5d02e65d901ec45d31c HTTP/1.1" 200 201 "-" "git/2.4.2" "-"
128.220.159.7 - - [26/Jan/2017:18:53:47 +0000] "GET /pollen-component.git/objects/62/de625f4c333f27fbe5789f3ae95fe2976d0e81 HTTP/1.1" 200 4231 "-" "git/2.4.2" "-"

Analysis

Both Racket and Git start by requesting /pollen-component.git/info/refs?service=git-upload-pack. But the User-Agents are different: while Git identifies itself as git/2.4.2, Racket identifies itself as git/1.9. This leads to a theory: version mismatch between Racket’s Git client and the Git server.

The second requests they make are different. Git requests /pollen-component.git/HEAD (which has a reference to master) and Racket requests /pollen-component.git/objects/info/packs (which is empty). This might or might not be relevant, and it might or might not be related to a version mismatch.

Also worth noting about Racket’s second request is that the User-Agent is different from the first one: Racket/6.8 (net/http-client). This leads to another theory: Racket is trying to do something clever. To explore this, let’s read again Racket’s output right before the stack trace:

Getting refs [dumb protocol]
Server does not support `shallow`
Downloading loose objects

It seems like Racket realized it’s working over HTTPS (dumb protocol). Also, it knows that HTTPS doesn’t support shallow Git clones, as the following snippet illustrates:

$ git clone --depth 1 https://git.leafac.com/pollen-component.git pollen-component
Cloning into 'pollen-component'...
fatal: dumb http transport does not support --depth

So maybe Racket is trying to be clever and hack a shallow clone anyway—probably with the good intention of saving resources by avoiding a full clone. But its cleverness backfires, which causes the error.


Of course, you know a lot more about this than I do, so please let me know what you think and how I can help.

leafac commented 7 years ago

Further investigation leads me to believe that this indeed is not an issue with the package website, but with git-checkout in Racket’s net library. So I ask you to please close this issue in favor of https://github.com/racket/racket/issues/1616

jeapostrophe commented 7 years ago

Good sleuthing!