Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests don't work with remote bootstrap server - missing type #25

Open
jensenhertz opened this issue Apr 14, 2022 · 5 comments
Open

Tests don't work with remote bootstrap server - missing type #25

jensenhertz opened this issue Apr 14, 2022 · 5 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@jensenhertz
Copy link

I'm running into curious problem with the library. I put up a test node on the server and replaced localhost in test.js. This causes the server to crash with the following error:

/app/node_modules/hyperswarm-proxy/messages.js:49
    if (!defined(obj.type)) throw new Error("type is required")
                                  ^

Error: type is required
    at encodingLength (/app/node_modules/hyperswarm-proxy/messages.js:49:35)
    at Object.encode (/app/node_modules/hyperswarm-proxy/messages.js:74:40)
    at Client.sendMessage (/app/node_modules/hyperswarm-proxy/index.js:105:26)
    at Client.onUpdated (/app/node_modules/hyperswarm-proxy/index.js:46:10)
    at Topic.handleUpdate (/app/node_modules/hyperswarm-proxy/server.js:161:14)
    at Topic.emit (node:events:527:28)
    at QueryStream.done (/app/node_modules/@hyperswarm/discovery/index.js:183:14)
    at QueryStream.emit (node:events:527:28)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

I also tried with the public bootstrap nodes mentioned in index.js and non of them work with the test. If I run the test with localhost server as it has by default, everything works perfectly 🤷

Am I doing something very wrong here or is this a bug?

@jensenhertz
Copy link
Author

I whipped up a quick browserified demo with the example code in README and the same problem occurs, the bootstrap server crashes with the type is required error.

@RangerMauve
Copy link
Owner

Is this with the test.js within this repo?

@RangerMauve
Copy link
Owner

I'm able to run npm run test without getting the error you mentioned.

What operating system and node.js version are you using?

@RangerMauve RangerMauve added bug Something isn't working help wanted Extra attention is needed labels Jun 4, 2022
@zacharygriffee
Copy link

zacharygriffee commented Jul 19, 2022

I am also getting the same error but, not in the tests, but in my personal project.

C:\WebstormProjects\sc-brain\node_modules\hyperswarm-proxy\messages.js:48
    if (!defined(obj.type)) throw new Error("type is required")
                            ^

Error: type is required
    at encodingLength (C:\WebstormProjects\sc-brain\node_modules\hyperswarm-proxy\messages.js:48:35)
    at Object.encode (C:\WebstormProjects\sc-brain\node_modules\hyperswarm-proxy\messages.js:72:40)
    at Client.sendMessage (C:\WebstormProjects\sc-brain\node_modules\hyperswarm-proxy\index.js:105:26)
    at Client.onUpdated (C:\WebstormProjects\sc-brain\node_modules\hyperswarm-proxy\index.js:46:10)
    at Topic.handleUpdate (C:\WebstormProjects\sc-brain\node_modules\hyperswarm-proxy\server.js:161:14)
    at Topic.emit (node:events:527:28)
    at QueryStream.done (C:\WebstormProjects\sc-brain\node_modules\@hyperswarm\discovery\index.js:183:14)
    at QueryStream.emit (node:events:527:28)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

I'm running Windows 10. With node v16.15.1 .

A few things to note:

  • I am using the hyperswarm-next (v3) npm package.
  • I've had this working in a previous personal project of mine about a year ago. I don't think I was using hyperswarm-next.

Here is the point of error.

image

Any additional information needed, let me know, and I'll try to supply it.

@zacharygriffee
Copy link

zacharygriffee commented Jul 19, 2022

I have a little more context as I dug in:

This is hyperswarm-proxy/index.js
image

EventType (from hyperswarm-proxy/messages.js) have these properties:

{
  "READY": 1,
  "JOIN": 2,
  "LEAVE": 3,
  "ON_STREAM_OPEN": 4,
  "ON_STREAM_CLOSE": 5,
  "ON_STREAM_DATA": 6,
  "ON_STREAM_ERROR": 7,
  "ON_PEER": 8,
  "CONNECT": 9
}

The type that is looked for in EventType (of hyperswarm-proxy/messages.js) is "ON_UPDATED" which doesn't exist there.

Even hyperswarm-proxy/index.js defines a method to call the "ON_UPDATED", but hyperswarm-proxy/messages.js doesn't implement.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants