RangerMauve / hypercore-fetch

Implementation of Fetch that uses the Hyper SDK for loading p2p content
MIT License
36 stars 12 forks source link

Issues with extensions #86

Open alphapapa opened 11 months ago

alphapapa commented 11 months ago

@RangerMauve @josephmturner

Doing some basic live testing in our meeting today, we determined that there are some issues regarding extension support. Mauve is saying now that there seems to be something fishy in the peer replication logic, and that it's necessary to reproduce the problem in unit tests to fully understand it.

So here is a list of the approximate basic steps we've been using to test this functionality:

  1. Adam and Joseph run (using blog.mauve.moe for convenience in place of a 32- or 64-character key-like string):

    curl --header "Accept: text/event-stream" --dump-header - 'http://localhost:4973/hyper/blog.mauve.moe/$/extensions/'

    This sends a GET request to open a long-polling connection to hopefully receive peer-open and peer-remove events when we begin listening to the same key/extension pair. (Note: We have received some peer-remove events, but have yet to see any peer-open events.)

  2. Joseph and Adam run:

    curl --dump-header - 'http://localhost:4973/hyper/blog.mauve.moe/$/extensions/.org.ushin.hyperdrive'

    This sends a GET request to begin listening on the .org.ushin.hyperdrive extension.

  3. Joseph and Adam run:

    curl --header "Accept: text/event-stream" --dump-header - 'http://localhost:4973/hyper/blog.mauve.moe/$/extensions/'

    This sends a GET request that should return a JSON object with an array of the list of extensions being listened to. When we tested this a few weeks ago, it seemed to work; when we started listening to a new extension, it would appear in the list. But now this list is always empty; I'm not sure why. It returns:

    
    HTTP/1.1 200 OK
    content-type: application/json
    Date: Tue, 08 Aug 2023 20:58:14 GMT
    Connection: keep-alive
    Keep-Alive: timeout=5
    Transfer-Encoding: chunked

[]

4.  Joseph and Adam run:

curl --dump-header - -d "foo=bar" 'http://localhost:4973/hyper/blog.mauve.moe/$/extensions/.org.ushin.hyperdrive'


That sends a POST request with an `application/x-www-form-urlencoded` data, which, if we understand correctly, the other peer should see an event for in the long-polling event-stream connection.  But we have yet to receive any such event in the several times we've tried this.

AFAIK that's as far as we've gotten.  Thanks for your help.
josephmturner commented 11 months ago

Output of curl 'http://localhost:4973/':

{
        "name": "hyper-gateway",
        "version": "3.4.2",
        "repository": {
                "type": "git",
                "url": "git+https://github.com/RangerMauve/hyper-gateway.git"
        },
        "dependencies": {
                "hypercore-fetch": "^9.7.0",
                "hyper-sdk": "^4.3.0"
        }
}
josephmturner commented 11 months ago

When both Adam and Joseph use one of Joseph's existing hyperdrive public keys (on which both of our machines are already replicating), we are able to send extension message back and forth.